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