File: constants.py

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (128 lines) | stat: -rw-r--r-- 6,046 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Copyright 2024 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from typing import Callable, Dict, List, Union
from mapper import Mapper
from license_type import LicenseType

def create_license_post_processing(*args: Mapper) -> Callable:
  def __update_metadata(metadata: Dict[str, Union[str, List[str]]]) -> Dict[
    str, Union[str, List[str]]]:
    for mapper in args:
      mapper.write(metadata)
    return metadata

  return __update_metadata

RAW_LICENSE_TO_FORMATTED_DETAILS = {
    "blessing": ("blessing", LicenseType.UNENCUMBERED, "SPDX-license-identifier-blessing"),
    "BSD": ("BSD", LicenseType.NOTICE, "SPDX-license-identifier-BSD"),
    "BSD-2-Clause": ("BSD_2_CLAUSE", LicenseType.NOTICE, "SPDX-license-identifier-BSD-2-Clause"),
    "BSD 3-Clause": (
        "BSD_3_CLAUSE", LicenseType.NOTICE,
        "SPDX-license-identifier-BSD-3-Clause"),
    "BSD-3-Clause": (
        "BSD_3_CLAUSE", LicenseType.NOTICE,
        "SPDX-license-identifier-BSD-3-Clause"),
    "Apache 2.0": (
        "APACHE_2_0", LicenseType.NOTICE, "SPDX-license-identifier-Apache-2.0"),
    # Different Apache 2.0 format used in Chromium.
    "Apache-2.0": (
        "APACHE_2_0", LicenseType.NOTICE, "SPDX-license-identifier-Apache-2.0"),
    "MIT": ("MIT", LicenseType.NOTICE, "SPDX-license-identifier-MIT"),
    "Unicode-3.0": (
        "UNICODE_3_0", LicenseType.NOTICE,
        "SPDX-license-identifier-Unicode-3.0"),
    "Unicode-DFS-2016": (
        "UNICODE", LicenseType.NOTICE,
        "SPDX-license-identifier-Unicode-DFS-2016"),
    "ICU": (
        "ICU", LicenseType.NOTICE,
        "SPDX-license-identifier-ICU"),
    "Zlib":
      ("ZLIB", LicenseType.RECIPROCAL, "SPDX-license-identifier-Zlib"),
    "MPL 1.1":
      ("MPL", LicenseType.RECIPROCAL, "SPDX-license-identifier-MPL-1.1"),
    "MPL-1.1":
      ("MPL", LicenseType.RECIPROCAL, "SPDX-license-identifier-MPL-1.1"),
    "MPL 2.0":
      ("MPL", LicenseType.RECIPROCAL, "SPDX-license-identifier-MPL-2.0"),
    "NCSA":
      ("NCSA", LicenseType.NOTICE, "SPDX-license-identifier-NCSA"),
    "unencumbered":
      ("UNENCUMBERED", LicenseType.UNENCUMBERED,
       "SPDX-license-identifier-Unlicense"),
}

# This is relative to the repo_directory passed in |update_license|
# post-processing is necessary for the cases where the license is not in the
# standard format, this can include two or more license (eg: "Apache 2 and MPL")
# or a single license that is not easily identifiable (eg: "BSDish")
#
# The current structure is Mapper(dictionary_key, expected_value, value_to_write)
POST_PROCESS_OPERATION = {
    "url/third_party/mozilla/README.chromium": create_license_post_processing(
        Mapper("License", ['MPLv2'], ["MPL 2.0"])),
    "third_party/apache-portable-runtime/README.chromium": create_license_post_processing(
        Mapper("License", ['Apache-2.0', 'dso', 'Zlib', 'ISC', 'BSD-4-Clause-UC'], ["Apache 2.0"])),
    "third_party/compiler-rt/README.chromium": create_license_post_processing(
        Mapper("License",
               ['NCSA', 'Apache-with-LLVM-Exception', 'MIT'],
               ["MIT"])),
    "third_party/libc++abi/README.chromium": create_license_post_processing(
        Mapper("License",
               ['NCSA', 'Apache-with-LLVM-Exception', 'MIT'],
               ["MIT"])),
    "third_party/libc++/README.chromium": create_license_post_processing(
        Mapper("License",
               ['NCSA', 'Apache-with-LLVM-Exception', 'MIT'],
               ["MIT"])),
    "third_party/boringssl/README.chromium": create_license_post_processing(
        Mapper("License", ['MIT', 'BSD-3-Clause', 'OpenSSL', 'ISC', 'SSLeay'], ["BSD"]),
        # TODO(b/360316861): Fix upstream by setting an explicit version to boringssl.
        Mapper("Version", "git", None)),
    "net/third_party/quiche/METADATA": create_license_post_processing(
        # TODO(b/360316861): Fix upstream by setting an explicit version to QUICHE.
        Mapper("Version", "git", None)),
    # TODO(b/360316861): Fix this upstream in Chromium.
    "third_party/quic_trace/README.chromium": create_license_post_processing(
        Mapper("Version", "git", "caa0a6eaba816ecb737f9a70782b7c80b8ac8dbc")),
    "third_party/metrics_proto/README.chromium": create_license_post_processing(
        Mapper("URL", "This is the canonical public repository", "Piper")),
    "third_party/boringssl/src/pki/testdata/nist-pkits/README.chromium": create_license_post_processing(
        Mapper("License", [
            'Public Domain: United States Government Work under 17 U.S.C. 105'],
               ["unencumbered"])),
}

# This is relative to the repo_directory passed in |update_license|
IGNORED_README = {
    # Not a third-party.
    "testing/android/native_test/README.chromium",
    # Not a third-party.
    "build/internal/README.chromium",
    # The real README.chromium lives nested inside each dependency.
    "third_party/android_deps/README.chromium",
    # This is not used in AOSP and not imported.
    "third_party/junit/README.chromium",
    # The real README.chromium lives nested inside each dependency.
    "third_party/androidx/README.chromium",
    # This is not used in AOSP and not imported.
    "third_party/aosp_dalvik/README.chromium",
    # b/369075726, those crates are missing LICENSE files upstream, once fixed
    # and imported, we will create a README for those.
    "third_party/rust/rstest/v0_17/README.chromium",
    "third_party/rust/rustc_demangle_capi/v0_1/README.chromium",
    "third_party/rust/rstest_macros/v0_17/README.chromium",
    "third_party/rust/codespan_reporting/v0_11/README.chromium",
    "third_party/rust/rstest_reuse/v0_5/README.chromium",
}

# READMEs that should have been discovered through gn, but were not, e.g.
# because they don't have a corresponding BUILD.gn file.
# TODO: http://crbug.com/389925432 - remove the need for this list.
INCLUDED_README = {
  "base/third_party/nspr/README.chromium",
  "url/third_party/mozilla/README.chromium",
}