xref: /aosp_15_r20/external/cronet/android/tools/license/constants.py (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright (C) 2024 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.
14
15from typing import Callable, Dict, List
16from mapper import Mapper
17
18
19def create_license_post_processing(*args: Mapper) -> Callable:
20  def __update_metadata(metadata: Dict[str, str | List[str]]) -> Dict[
21    str, str | List[str]]:
22    for mapper in args:
23      mapper.write(metadata)
24    return metadata
25
26  return __update_metadata
27
28
29# This is relative to the repo_directory passed in |update_license|
30# post-processing is necessary for the cases where the license is not in the
31# standard format, this can include two or more license (eg: "Apache 2 and MPL")
32# or a single license that is not easily identifiable (eg: "BSDish")
33#
34# The current structure is Mapper(dictionary_key, expected_value, value_to_write)
35POST_PROCESS_OPERATION = {
36    "base/third_party/nspr/README.chromium": create_license_post_processing(
37        Mapper("License", ['MPL 1.1/GPL 2.0/LGPL 2.1'], ["MPL 1.1"])),
38    "url/third_party/mozilla/README.chromium": create_license_post_processing(
39        Mapper("License", ['BSD and MPL 1.1/GPL 2.0/LGPL 2.1'],
40               ["BSD"])),
41    "third_party/libc++abi/README.chromium": create_license_post_processing(
42        Mapper("License",
43               ['MIT',
44                'University of Illinois/NCSA Open Source License'],
45               ["MIT"])),
46    "third_party/libc++/README.chromium": create_license_post_processing(
47        Mapper("License",
48               ['MIT',
49                'University of Illinois/NCSA Open Source License'],
50               ["MIT"])),
51    "third_party/boringssl/README.chromium": create_license_post_processing(
52        Mapper("License", ['BSDish'], ["BSD"]),
53        # TODO(b/360316861): Fix upstream by setting an explicit version to boringssl.
54        Mapper("Version", "git", None)),
55    "net/third_party/quiche/METADATA": create_license_post_processing(
56        # TODO(b/360316861): Fix upstream by setting an explicit version to QUICHE.
57        Mapper("Version", "git", None)),
58    # TODO(b/360316861): Fix this upstream in Chromium.
59    "third_party/quic_trace/README.chromium": create_license_post_processing(
60        Mapper("Version", "git", "caa0a6eaba816ecb737f9a70782b7c80b8ac8dbc")),
61    "third_party/metrics_proto/README.chromium": create_license_post_processing(
62        Mapper("URL", "This is the canonical public repository", "Piper")),
63    "third_party/boringssl/src/pki/testdata/nist-pkits/README.chromium": create_license_post_processing(
64        Mapper("License", [
65            'Public Domain: United States Government Work under 17 U.S.C. 105'],
66               ["unencumbered"]),
67        Mapper("License File", "", "N/A")),
68    "third_party/rust/unicode_ident/v1/README.chromium": create_license_post_processing(
69        Mapper("License", [
70            'Apache 2.0 AND Unicode License Agreement - Data Files and Software (2016)'],
71               ["Apache 2.0", "Unicode"])),
72}
73
74# This is relative to the repo_directory passed in |update_license|
75IGNORED_README = {
76    # Not a third-party.
77    "testing/android/native_test/README.chromium",
78    # Not a third-party.
79    "build/internal/README.chromium",
80    # b/369075726, those crates are missing LICENSE files upstream, once fixed
81    # and imported, we will create a README for those.
82    "third_party/rust/rstest/v0_17/README.chromium",
83    "third_party/rust/rustc_demangle_capi/v0_1/README.chromium",
84    "third_party/rust/rstest_macros/v0_17/README.chromium",
85    "third_party/rust/codespan_reporting/v0_11/README.chromium",
86    "third_party/rust/rstest_reuse/v0_5/README.chromium",
87}
88