xref: /aosp_15_r20/external/bazelbuild-rules_license/rules/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"""Basic providers for license rules.
15
16This file should only contain the basic providers needed to create
17license and package_info declarations. Providers needed to gather
18them are declared in other places.
19"""
20
21LicenseKindInfo = provider(
22    doc = """Provides information about a license_kind instance.""",
23    fields = {
24        "conditions": "list(string): List of conditions to be met when using this packages under this license.",
25        "label": "Label: The full path to the license kind definition.",
26        "long_name": "string: Human readable license name",
27        "name": "string: Canonical license name",
28    },
29)
30
31LicenseInfo = provider(
32    doc = """Provides information about a license instance.""",
33    fields = {
34        "copyright_notice": "string: Human readable short copyright notice",
35        "label": "Label: label of the license rule",
36        "license_kinds": "list(LicenseKindInfo): License kinds ",
37        "license_text": "string: The license file path",
38        "namespace": "string: namespace of the license rule",
39        # TODO(aiuto): move to PackageInfo
40        "package_name": "string: Human readable package name",
41        "package_url": "URL from which this package was downloaded.",
42        "package_version": "Human readable version string",
43    },
44)
45
46PackageInfo = provider(
47    doc = """Provides information about a package.""",
48    fields = {
49        "type": "string: How to interpret data",
50        "label": "Label: label of the package_info rule",
51        "package_name": "string: Human readable package name",
52        "package_url": "string: URL from which this package was downloaded.",
53        "package_version": "string: Human readable version string",
54    },
55)
56
57# This is more extensible. Because of the provider implementation, having a big
58# dict of values rather than named fields is not much more costly.
59# Design choice.  Replace data with actual providers, such as PackageInfo
60ExperimentalMetadataInfo = provider(
61    doc = """Generic bag of metadata.""",
62    fields = {
63        "type": "string: How to interpret data",
64        "label": "Label: label of the metadata rule",
65        "data": "String->any: Map of names to values",
66    }
67)
68