summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2023-03-28 10:39:12 +0200
committerMichal Klocek <michal.klocek@qt.io>2023-03-29 12:37:40 +0000
commite41707d576a21b3d9049073604b7546eca2f1390 (patch)
treef8787e5b57b477a33666696f8ed2f934ccecff5e
parent8b8de6420db588260120e146130944157d6dff56 (diff)
downloadqtwebengine-chromium-e41707d576a21b3d9049073604b7546eca2f1390.tar.gz
Add support for custom gn binary to license generator
In case of generating licenses using gn targets add support for gn binary location. Also add a way to skip project generation, which in case of webengine will not work as we use out of root configutation and is not needed as this is not a part of gn recursive call. Task-number: QTBUG-88482 Change-Id: Ie2870bcadc6b1ab3e443374fdee6be29ba614c08 Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/469344 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rwxr-xr-xchromium/tools/licenses.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/chromium/tools/licenses.py b/chromium/tools/licenses.py
index ba4cf4f0774..1f9949c66a4 100755
--- a/chromium/tools/licenses.py
+++ b/chromium/tools/licenses.py
@@ -622,7 +622,7 @@ def GetThirdPartyDepsFromGNDepsOutput(gn_deps, target_os):
return sorted(third_party_deps)
-def FindThirdPartyDeps(gn_out_dir, gn_target, target_os):
+def FindThirdPartyDeps(gn_binary, gn_out_dir, gn_target, gn_generate, target_os):
if not gn_out_dir:
raise RuntimeError("--gn-out-dir is required if --gn-target is used.")
@@ -633,11 +633,14 @@ def FindThirdPartyDeps(gn_out_dir, gn_target, target_os):
try:
with tempfile.TemporaryDirectory(dir=gn_out_dir) as tmp_dir:
shutil.copy(os.path.join(gn_out_dir, "args.gn"), tmp_dir)
- subprocess.check_output(
- [_GnBinary(), "gen",
- "--root=%s" % _REPOSITORY_ROOT, tmp_dir])
+ if not gn_generate:
+ subprocess.check_output(
+ [gn_binary, "gen",
+ "--root=%s" % _REPOSITORY_ROOT, tmp_dir])
+ else:
+ tmp_dir = gn_out_dir
gn_deps = subprocess.check_output([
- _GnBinary(), "desc",
+ gn_binary, "desc",
"--root=%s" % _REPOSITORY_ROOT, tmp_dir, gn_target, "deps",
"--as=buildfile", "--all"
])
@@ -682,8 +685,10 @@ def GenerateCredits(file_template_file,
entry_template_file,
output_file,
target_os,
+ gn_binary,
gn_out_dir,
gn_target,
+ gn_generate,
extra_third_party_dirs=None,
depfile=None):
"""Generate about:credits."""
@@ -714,7 +719,7 @@ def GenerateCredits(file_template_file,
}
if gn_target:
- third_party_dirs = FindThirdPartyDeps(gn_out_dir, gn_target, target_os)
+ third_party_dirs = FindThirdPartyDeps(gn_binary, gn_out_dir, gn_target, gn_generate, target_os)
# Sanity-check to raise a build error if invalid gn_... settings are
# somehow passed to this script.
@@ -824,7 +829,7 @@ def _ReadFile(path):
return f.read()
-def GenerateLicenseFile(output_file, gn_out_dir, gn_target, target_os):
+def GenerateLicenseFile(output_file, gn_binary, gn_out_dir, gn_target, gn_generate, target_os):
"""Generate a plain-text LICENSE file which can be used when you ship a part
of Chromium code (specified by gn_target) as a stand-alone library
(e.g., //ios/web_view).
@@ -832,7 +837,7 @@ def GenerateLicenseFile(output_file, gn_out_dir, gn_target, target_os):
The LICENSE file contains licenses of both Chromium and third-party
libraries which gn_target depends on. """
- third_party_dirs = FindThirdPartyDeps(gn_out_dir, gn_target, target_os)
+ third_party_dirs = FindThirdPartyDeps(gn_binary, gn_out_dir, gn_target, gn_generate, target_os)
# Start with Chromium's LICENSE file.
content = [_ReadFile('LICENSE')]
@@ -870,6 +875,8 @@ def main():
parser.add_argument(
'--gn-out-dir', help='GN output directory for scanning dependencies.')
parser.add_argument('--gn-target', help='GN target to scan for dependencies.')
+ parser.add_argument('--gn-binary', help="GN binary location.")
+ parser.add_argument('--gn-generate', action='store_false', help='Generates gn project.')
parser.add_argument(
'command', choices=['help', 'scan', 'credits', 'license_file'])
parser.add_argument('output_file', nargs='?')
@@ -878,19 +885,25 @@ def main():
args.extra_third_party_dirs = build_utils.ParseGnList(
args.extra_third_party_dirs)
+ if not args.gn_binary:
+ gn_binary = _GnBinary()
+ else:
+ gn_binary = args.gn_binary
+
if args.command == 'scan':
if not ScanThirdPartyDirs():
return 1
elif args.command == 'credits':
if not GenerateCredits(args.file_template, args.entry_template,
- args.output_file, args.target_os, args.gn_out_dir,
- args.gn_target, args.extra_third_party_dirs,
+ args.output_file, args.target_os, gn_binary,
+ args.gn_out_dir,
+ args.gn_target, args.gn_generate, args.extra_third_party_dirs,
args.depfile):
return 1
elif args.command == 'license_file':
try:
- GenerateLicenseFile(args.output_file, args.gn_out_dir, args.gn_target,
- args.target_os)
+ GenerateLicenseFile(args.output_file, gn_binary, args.gn_out_dir, gn_binary, args.gn_target,
+ args.gn_generate, args.target_os)
except LicenseError as e:
print("Failed to parse README.chromium: {}".format(e))
return 1