• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The Bazel Authors. All rights reserved.
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.
14
15"""
16Definition of the BootClassPathInfo provider.
17"""
18
19load("@bazel_skylib//lib:paths.bzl", "paths")
20
21visibility(
22    ["//java/..."],
23)
24
25def _init(bootclasspath = [], auxiliary = [], system = None):
26    """The <code>BootClassPathInfo</code> constructor.
27
28    Args:
29        bootclasspath: ([File])
30        auxiliary: ([File])
31        system: ([File]|File|None)
32    """
33    if not system:  # None or []
34        system_inputs = depset()
35        system_path = None
36    elif type(system) == "File":
37        system_inputs = depset([system])
38        if not system.is_directory:
39            fail("for system,", system, "is not a directory")
40        system_path = system.path
41    elif type(system) == type([]):
42        system_inputs = depset(system)
43        system_paths = [input.path for input in system if input.basename == "release"]
44        if not system_paths:
45            fail("for system, expected inputs to contain 'release'")
46        system_path = paths.dirname(system_paths[0])
47    else:
48        fail("for system, got", type(system), ", want File, sequence, or None")
49
50    return {
51        "bootclasspath": depset(bootclasspath),
52        "_auxiliary": depset(auxiliary),
53        "_system_inputs": system_inputs,
54        "_system_path": system_path,
55    }
56
57BootClassPathInfo, _new_bootclasspathinfo = provider(
58    doc = "Information about the system APIs for a Java compilation.",
59    fields = [
60        "bootclasspath",
61        # private
62        "_auxiliary",
63        "_system_inputs",
64        "_system_path",
65    ],
66    init = _init,
67)
68