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 21load( 22 "@rules_license//rules_gathering:gathering_providers.bzl", 23 _private_TransitiveLicensesInfo = "TransitiveLicensesInfo", 24) 25 26LicenseKindInfo = provider( 27 doc = """Provides information about a license_kind instance.""", 28 fields = { 29 "conditions": "list(string): List of conditions to be met when using this packages under this license.", 30 "label": "Label: The full path to the license kind definition.", 31 "long_name": "string: Human readable license name", 32 "name": "string: Canonical license name", 33 }, 34) 35 36LicenseInfo = provider( 37 doc = """Provides information about a license instance.""", 38 fields = { 39 "copyright_notice": "string: Human readable short copyright notice", 40 "label": "Label: label of the license rule", 41 "license_kinds": "list(LicenseKindInfo): License kinds ", 42 "license_text": "string: The license file path", 43 # TODO(aiuto): move to PackageInfo 44 "package_name": "string: Human readable package name", 45 "package_url": "URL from which this package was downloaded.", 46 "package_version": "Human readable version string", 47 }, 48) 49 50PackageInfo = provider( 51 doc = """Provides information about a package.""", 52 fields = { 53 "type": "string: How to interpret data", 54 "label": "Label: label of the package_info rule", 55 "package_name": "string: Human readable package name", 56 "package_url": "string: URL from which this package was downloaded.", 57 "package_version": "string: Human readable version string", 58 "purl": "string: package url matching the purl spec (https://github.com/package-url/purl-spec)", 59 }, 60) 61 62# This is more extensible. Because of the provider implementation, having a big 63# dict of values rather than named fields is not much more costly. 64# Design choice. Replace data with actual providers, such as PackageInfo 65ExperimentalMetadataInfo = provider( 66 doc = """Generic bag of metadata.""", 67 fields = { 68 "type": "string: How to interpret data", 69 "label": "Label: label of the metadata rule", 70 "data": "String->any: Map of names to values", 71 }, 72) 73 74# Deprecated: Use write_licenses_info instead. 75TransitiveLicensesInfo = _private_TransitiveLicensesInfo 76