xref: /aosp_15_r20/external/bazelbuild-rules_license/rules/private/gathering_providers.bzl (revision f578df4fd057ffe2023728444759535685631548)
1# Copyright 2022 Google LLC
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# https://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"""Providers for transitively gathering all license and package_info targets.
15
16Warning: This is private to the aspect that walks the tree. The API is subject
17to change at any release.
18"""
19
20LicensedTargetInfo = provider(
21    doc = """Lists the licenses directly used by a single target.""",
22    fields = {
23        "target_under_license": "Label: The target label",
24        "licenses": "list(label of a license rule)",
25    },
26)
27
28def licenses_info():
29    return provider(
30        doc = """The transitive set of licenses used by a target.""",
31        fields = {
32            "target_under_license": "Label: The top level target label.",
33            "deps": "depset(LicensedTargetInfo): The transitive list of dependencies that have licenses.",
34            "licenses": "depset(LicenseInfo)",
35            "traces": "list(string) - diagnostic for tracing a dependency relationship to a target.",
36        },
37    )
38
39# This provider is used by the aspect that is used by manifest() rules.
40TransitiveLicensesInfo = licenses_info()
41
42TransitiveMetadataInfo = provider(
43    doc = """The transitive set of licenses used by a target.""",
44    fields = {
45        "top_level_target": "Label: The top level target label we are examining.",
46        "other_metadata": "depset(ExperimentalMetatdataInfo)",
47        "licenses": "depset(LicenseInfo)",
48        "package_info": "depset(PackageInfo)",
49
50        "target_under_license": "Label: A target which will be associated with some licenses.",
51        "deps": "depset(LicensedTargetInfo): The transitive list of dependencies that have licenses.",
52        "traces": "list(string) - diagnostic for tracing a dependency relationship to a target.",
53    },
54)
55