1*7594170eSAndroid Build Coastguard Worker# Copyright (C) 2022 The Android Open Source Project 2*7594170eSAndroid Build Coastguard Worker# 3*7594170eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*7594170eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*7594170eSAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*7594170eSAndroid Build Coastguard Worker# 7*7594170eSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*7594170eSAndroid Build Coastguard Worker# 9*7594170eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*7594170eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*7594170eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*7594170eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*7594170eSAndroid Build Coastguard Worker# limitations under the License. 14*7594170eSAndroid Build Coastguard Workerload(":java_system_modules.bzl", "SystemInfo") 15*7594170eSAndroid Build Coastguard Worker 16*7594170eSAndroid Build Coastguard Workerdef _bootclasspath_impl(ctx): 17*7594170eSAndroid Build Coastguard Worker infos = [b[JavaInfo] for b in ctx.attr.bootclasspath] 18*7594170eSAndroid Build Coastguard Worker java_info = java_common.merge(infos) 19*7594170eSAndroid Build Coastguard Worker 20*7594170eSAndroid Build Coastguard Worker # TODO: b/304657641 - system modules propagate java_info, including compile jars, we could consider consolidating bootclasspaths from system modules for the toolchains 21*7594170eSAndroid Build Coastguard Worker bootclasspath_jars = java_info.compile_jars.to_list() 22*7594170eSAndroid Build Coastguard Worker 23*7594170eSAndroid Build Coastguard Worker return java_common.BootClassPathInfo( 24*7594170eSAndroid Build Coastguard Worker bootclasspath = bootclasspath_jars, 25*7594170eSAndroid Build Coastguard Worker system = ctx.attr.system[SystemInfo].system if ctx.attr.system else None, 26*7594170eSAndroid Build Coastguard Worker auxiliary = [jar for b in ctx.attr.auxiliary for jar in b[JavaInfo].compile_jars.to_list()], 27*7594170eSAndroid Build Coastguard Worker ) 28*7594170eSAndroid Build Coastguard Worker 29*7594170eSAndroid Build Coastguard Workerbootclasspath = rule( 30*7594170eSAndroid Build Coastguard Worker implementation = _bootclasspath_impl, 31*7594170eSAndroid Build Coastguard Worker attrs = { 32*7594170eSAndroid Build Coastguard Worker "bootclasspath": attr.label_list( 33*7594170eSAndroid Build Coastguard Worker providers = [JavaInfo], 34*7594170eSAndroid Build Coastguard Worker doc = "The list of libraries to use as javac's --bootclasspath argument.", 35*7594170eSAndroid Build Coastguard Worker ), 36*7594170eSAndroid Build Coastguard Worker "system": attr.label( 37*7594170eSAndroid Build Coastguard Worker providers = [SystemInfo], 38*7594170eSAndroid Build Coastguard Worker doc = "The java_system_modules target to use as javac's --system argument.", 39*7594170eSAndroid Build Coastguard Worker ), 40*7594170eSAndroid Build Coastguard Worker "auxiliary": attr.label_list( 41*7594170eSAndroid Build Coastguard Worker providers = [JavaInfo], 42*7594170eSAndroid Build Coastguard Worker doc = "The list of libraries to include first in javac's --classpath.", 43*7594170eSAndroid Build Coastguard Worker ), 44*7594170eSAndroid Build Coastguard Worker }, 45*7594170eSAndroid Build Coastguard Worker provides = [java_common.BootClassPathInfo], 46*7594170eSAndroid Build Coastguard Worker doc = """Provides BootClassPathInfo to a Java toolchain. 47*7594170eSAndroid Build Coastguard Worker 48*7594170eSAndroid Build Coastguard Workerthe java_common.BootClassPathInfo provider is used by a Java toolchain to 49*7594170eSAndroid Build Coastguard Workerset javac's --bootclasspath and --system arguments. It can also optionally add 50*7594170eSAndroid Build Coastguard Workerto the classpath before anything else gets added to it. This rule generates this 51*7594170eSAndroid Build Coastguard Workerprovider from a list of JavaInfo-providing targets for --bootclasspath and 52*7594170eSAndroid Build Coastguard Worker--classpath, and from a single SystemInfo-providing target for --system. 53*7594170eSAndroid Build Coastguard Worker""", 54*7594170eSAndroid Build Coastguard Worker) 55