ckerr

#56180: build: generate LICENSES.chromium.html without patching licenses.py

Merged
Created: Dec 3, 2026, 9:25:06 PM
Merged: Dec 4, 2026, 10:59:44 AM
8 comments
Target: main

Part of #56164.

Replaces patches/chromium/add_electron_deps_to_license_credits_file.patch with an Electron-owned metadata file (build/licenses/README.chromium) and a small wrapper script (script/generate-credits.py) that //electron:chromium_licenses runs from BUILD.gn.

Summary of Changes

  • Add build/licenses/README.chromium: Describes the shipped Electron DEPS checkouts that have no metadata file of their own (Node.js, Squirrel, Mantle, ReactiveObjC, Sparkle), using licenses.py's multi-dependency format (DEPENDENCY DIVIDER) and //-rooted License File paths. licenses.py reserves SPECIAL_CASES for historical directories and asks new cases to use README.chromium.
  • Add script/generate-credits.py: Checks that file with licenses.ParseDir and fails on any error, then runs licenses.main() with the file's directory added through --extra-third-party-dirs, the hook Chromium's own about_credits action offers downstream projects. It overrides none of licenses.py's globals. The check is needed because licenses.py credits silently drops an entry it can't parse or whose license file is missing.
  • Fix latent omission of Mantle, ReactiveObjC, and Sparkle:
    • Under the old patch, squirrel.mac/vendor/{Mantle,ReactiveObjC,Sparkle} lived under vendor/ (not third_party/) and were never added to ADDITIONAL_PATHS, so FindThirdPartyDirs never visited them and all three were silently omitted from LICENSES.chromium.html.
    • In addition, Mantle used lowercase vendor/mantle (failing on case-sensitive Linux filesystems where DEPS checks out vendor/Mantle), had a str-typed "License File" instead of a list, and the entries omitted "Shipped": "yes".
  • Update BUILD.gn: Replace copy("chromium_licenses") depending on //components/resources:about_credits with a generate_chromium_licenses = is_official_build GN arg:
    • When true, action("chromium_licenses") runs //electron/script/generate-credits.py with --target-os=$target_os and --depfile to produce $root_build_dir/LICENSES.chromium.html. build/licenses/README.chromium is one of its inputs.
    • When false (default developer/testing builds), copy("chromium_licenses") copies //components/resources/sample_credits.html so non-official builds stay fast.
  • Set generate_about_credits = false in build/args/all.gn: Electron has no chrome://credits page, so this prevents official builds from running a redundant, unpatched licenses.py filesystem scan inside //components/resources:about_credits. IDR_ABOUT_UI_CREDITS_HTML still ships in components_resources.pak, now holding the sample page.
  • Remove patches/chromium/add_electron_deps_to_license_credits_file.patch and its entry in patches/chromium/.patches.
  • Siso hygiene: Verified in build/config/siso/denylist.star and main.star that Python action() scripts run locally unless -config=default-remote is enabled (which Electron does not use), matching Electron's existing //electron/script/*.py actions.

Verification

PR CI doesn't run this action: PR builds use testing.gn, where generate_chromium_licenses is false. Everything below was run locally on main (Chromium 160.0.8193.0).

  • Full-tree run: Ran script/generate-credits.py credits --target-os=linux --depfile <file> <output>, the arguments BUILD.gn passes. It wrote a 5,828,899-byte LICENSES.chromium.html with 499 entries, including Node.js, Squirrel, Mantle, ReactiveObjC, and Sparkle with their full license texts. The output is byte-identical to that of the previous, SPECIAL_CASES-based revision of the script (7025b45).
  • Compared with the old patch: Diffed LICENSES.chromium.html before vs. after (against unpatched Chromium 160.0.8193.0 tools/licenses/licenses.py): zero removed lines; all upstream Chromium licenses plus Node.js and Squirrel are byte-for-byte identical, and Mantle, ReactiveObjC, and Sparkle now appear with their full license texts.
  • GN and Siso: Generated a scratch out dir from release.gn (is_official_build = true, so generate_chromium_licenses defaults to true) and built electron:chromium_licenses with siso -offline. The action succeeded, and its output matched the direct run byte for byte.
  • Incremental builds, in the same out dir:
    • A rebuild with no changes runs 0 steps.
    • Touching build/licenses/README.chromium (an inputs entry) reruns the action. licenses.py doesn't rewrite unchanged output, so the file's mtime stays put and nothing downstream rebuilds.
    • Touching third_party/squirrel.mac/vendor/Sparkle/LICENSE, which is tracked only through the depfile, reruns the action.
  • Error handling, with the tree walk stubbed out: pointing a README.chromium entry's License File at a missing file makes the script fail before it writes anything. The SPECIAL_CASES revision passed the same test and rendered Sparkle with an empty license, because licenses.py keeps SPECIAL_CASES entries whose license file is missing.
  • Build modes:
    • testing.gn (is_official_build = false): //electron:chromium_licenses and //components/resources:about_credits both resolve to copy (sample_credits.html).
    • release.gn (is_official_build = true): //electron:chromium_licenses resolves to action (script/generate-credits.py), and //components/resources:about_credits stays copy (sample_credits.html).
  • Lint: pylint, gn format, and gn check pass on every commit (pre-commit hooks). check-patch-diff.mts passed on the first commit; the later commits don't touch patches/.

Notes: none

Backports

43-x-y
Merged
PR Number
#56208
Merged At
Dec 4, 2026, 3:32:45 PM
Released In
Not yet
Release Date
Not yet
44-x-y
Merged
PR Number
#56207
Merged At
Dec 4, 2026, 3:32:42 PM
Released In
Not yet
Release Date
Not yet
45-x-y
Merged
PR Number
#56206
Merged At
Dec 4, 2026, 3:32:44 PM
Released In
Not yet
Release Date
Not yet
46-x-y
Merged
PR Number
#56200
Merged At
Dec 4, 2026, 3:52:38 PM
Released In
Not yet
Release Date
Not yet

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron