Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: components/cronet/tools/cronet_licenses.py

Issue 1934083002: [Cronet] Use gn desc deps to find third_party licenses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add components/cronet/ios/BUILD.gn Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/cronet/tools/cronet_licenses.py
diff --git a/components/cronet/tools/cronet_licenses.py b/components/cronet/tools/cronet_licenses.py
index 63a7b07e21d47f79294e7953dd6bbadbff55daf4..47feeeaa46be59b8e67b824604617e1bf46dce3a 100755
--- a/components/cronet/tools/cronet_licenses.py
+++ b/components/cronet/tools/cronet_licenses.py
@@ -11,6 +11,7 @@ it depends. Based on android_webview/tools/webview_licenses.py.
import optparse
import os
+import subprocess
import sys
import textwrap
@@ -20,6 +21,14 @@ REPOSITORY_ROOT = os.path.abspath(os.path.join(
sys.path.append(os.path.join(REPOSITORY_ROOT, 'tools'))
import licenses
+third_party_dirs = [
+ 'base/third_party/libevent',
+ 'third_party/ashmem',
+ 'third_party/boringssl',
+ 'third_party/modp_b64',
+ 'third_party/zlib',
+]
+
def _ReadFile(path):
"""Reads a file from disk.
Args:
@@ -35,15 +44,6 @@ def GenerateLicense():
Returns:
The contents of the LICENSE file.
"""
- # TODO(mef): Generate list of third_party libraries using checkdeps.
- third_party_dirs = [
- 'base/third_party/libevent',
- 'third_party/ashmem',
- 'third_party/boringssl',
- 'third_party/modp_b64',
- 'third_party/zlib',
- ]
-
# Start with Chromium's LICENSE file
content = [_ReadFile('LICENSE')]
@@ -52,7 +52,7 @@ def GenerateLicense():
metadata = licenses.ParseDir(directory, REPOSITORY_ROOT,
require_license_file=True)
content.append('-' * 20)
- content.append(directory)
+ content.append(directory.split("/")[-1])
content.append('-' * 20)
license_file = metadata['License File']
if license_file and license_file != licenses.NOT_SHIPPED:
@@ -61,6 +61,17 @@ def GenerateLicense():
return '\n'.join(content)
+def FindThirdPartyDeps(gn_out_dir):
+ gn_deps = subprocess.check_output(["gn", "desc", gn_out_dir, \
+ "net", "deps", "--as=buildfile", "--all"])
+ third_party_deps = []
+ for build_dep in gn_deps.split():
+ if ("third_party" in build_dep and build_dep.endswith("/BUILD.gn")):
+ third_party_deps.append(build_dep.replace("/BUILD.gn", ""))
brettw 2016/05/03 17:59:00 The BUILD file in a third party directory isn't ne
mef 2016/05/03 21:50:20 Argh, that's unfortunate! Luckily Cronet's set of
+ third_party_deps.sort()
+ return third_party_deps
+
+
def main():
class FormatterWithNewLines(optparse.IndentedHelpFormatter):
def format_description(self, description):
@@ -70,11 +81,17 @@ def main():
parser = optparse.OptionParser(formatter=FormatterWithNewLines(),
usage='%prog command [options]')
+ parser.add_option('--gn_out_dir', help='Directory of gn output.')
parser.description = (__doc__ +
'\nCommands:\n' \
' license [filename]\n' \
' Generate Cronet LICENSE to filename or stdout.\n')
(_, args) = parser.parse_args()
+
+ if _.gn_out_dir:
+ global third_party_dirs
+ third_party_dirs = FindThirdPartyDeps(_.gn_out_dir)
+
if not args:
parser.print_help()
return 1

Powered by Google App Engine
This is Rietveld 408576698