Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Utility for checking and processing licensing information in third_party | 6 """Utility for checking and processing licensing information in third_party |
| 7 directories. | 7 directories. |
| 8 | 8 |
| 9 Usage: licenses.py <command> | 9 Usage: licenses.py <command> |
| 10 | 10 |
| 11 Commands: | 11 Commands: |
| 12 scan scan third_party directories, verifying that we have licensing info | 12 scan scan third_party directories, verifying that we have licensing info |
| 13 credits generate about:credits on stdout | 13 credits generate about:credits on stdout |
| 14 | 14 |
| 15 (You can also import this as a module.) | 15 (You can also import this as a module.) |
| 16 """ | 16 """ |
| 17 | 17 |
| 18 import argparse | 18 import argparse |
| 19 import cgi | 19 import cgi |
| 20 import os | 20 import os |
| 21 import re | |
| 21 import subprocess | 22 import subprocess |
| 22 import sys | 23 import sys |
| 23 | 24 |
| 24 # TODO(agrieve): Move build_utils.WriteDepFile into a non-android directory. | 25 # TODO(agrieve): Move build_utils.WriteDepFile into a non-android directory. |
| 25 _REPOSITORY_ROOT = os.path.dirname(os.path.dirname(__file__)) | 26 _REPOSITORY_ROOT = os.path.dirname(os.path.dirname(__file__)) |
| 26 sys.path.append(os.path.join(_REPOSITORY_ROOT, 'build/android/gyp/util')) | 27 sys.path.append(os.path.join(_REPOSITORY_ROOT, 'build/android/gyp/util')) |
| 27 import build_utils | 28 import build_utils |
| 28 | 29 |
| 29 | 30 |
| 30 # Paths from the root of the tree to directories to skip. | 31 # Paths from the root of the tree to directories to skip. |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 | 481 |
| 481 def FindThirdPartyDeps(gn_out_dir, gn_target): | 482 def FindThirdPartyDeps(gn_out_dir, gn_target): |
| 482 if not gn_out_dir: | 483 if not gn_out_dir: |
| 483 raise RuntimeError("--gn-out-dir is required if --gn-target is used.") | 484 raise RuntimeError("--gn-out-dir is required if --gn-target is used.") |
| 484 | 485 |
| 485 gn_deps = subprocess.check_output([_GnBinary(), "desc", gn_out_dir, | 486 gn_deps = subprocess.check_output([_GnBinary(), "desc", gn_out_dir, |
| 486 gn_target, | 487 gn_target, |
| 487 "deps", "--as=buildfile", "--all"]) | 488 "deps", "--as=buildfile", "--all"]) |
| 488 third_party_deps = set() | 489 third_party_deps = set() |
| 489 for build_dep in gn_deps.split(): | 490 for build_dep in gn_deps.split(): |
| 490 if ("third_party" in build_dep and | 491 # Note that it must always return the direct sub-directory of |
| 491 os.path.basename(build_dep) == "BUILD.gn"): | 492 # third_party. e.g.: |
| 492 third_party_deps.add(os.path.dirname(build_dep)) | 493 # .../third_party/cld_3/src/src/BUILD.gn -> .../third_party/cld_3 |
| 494 m = re.search(r"^(.+/third_party/[^/]+)/(.+/)?BUILD\.gn$", build_dep) | |
|
Paweł Hajdan Jr.
2017/04/06 11:55:09
nit: Use single quotes ' .
Hiroshi Ichikawa
2017/04/07 05:07:51
Done.
| |
| 495 if m: | |
| 496 third_party_deps.add(m.group(1)) | |
| 493 return third_party_deps | 497 return third_party_deps |
| 494 | 498 |
| 495 | 499 |
| 496 def ScanThirdPartyDirs(root=None): | 500 def ScanThirdPartyDirs(root=None): |
| 497 """Scan a list of directories and report on any problems we find.""" | 501 """Scan a list of directories and report on any problems we find.""" |
| 498 if root is None: | 502 if root is None: |
| 499 root = os.getcwd() | 503 root = os.getcwd() |
| 500 third_party_dirs = FindThirdPartyDirsWithFiles(root) | 504 third_party_dirs = FindThirdPartyDirsWithFiles(root) |
| 501 | 505 |
| 502 errors = [] | 506 errors = [] |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 args.output_file, args.target_os, | 635 args.output_file, args.target_os, |
| 632 args.gn_out_dir, args.gn_target, args.depfile): | 636 args.gn_out_dir, args.gn_target, args.depfile): |
| 633 return 1 | 637 return 1 |
| 634 else: | 638 else: |
| 635 print __doc__ | 639 print __doc__ |
| 636 return 1 | 640 return 1 |
| 637 | 641 |
| 638 | 642 |
| 639 if __name__ == '__main__': | 643 if __name__ == '__main__': |
| 640 sys.exit(main()) | 644 sys.exit(main()) |
| OLD | NEW |