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 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 third_party_dirs.add(dir) | 455 third_party_dirs.add(dir) |
456 | 456 |
457 return third_party_dirs | 457 return third_party_dirs |
458 | 458 |
459 | 459 |
460 def FindThirdPartyDirsWithFiles(root): | 460 def FindThirdPartyDirsWithFiles(root): |
461 third_party_dirs = FindThirdPartyDirs(PRUNE_PATHS, root) | 461 third_party_dirs = FindThirdPartyDirs(PRUNE_PATHS, root) |
462 return FilterDirsWithFiles(third_party_dirs, root) | 462 return FilterDirsWithFiles(third_party_dirs, root) |
463 | 463 |
464 | 464 |
| 465 # Many builders do not contain 'gn' in their PATH, so use the GN binary from |
| 466 # //buildtools. |
| 467 def _GnBinary(): |
| 468 exe = 'gn' |
| 469 if sys.platform == 'linux2': |
| 470 subdir = 'linux64' |
| 471 elif sys.platform == 'darwin': |
| 472 subdir = 'mac' |
| 473 elif sys.platform == 'win32': |
| 474 subdir, exe = 'win', 'gn.exe' |
| 475 else: |
| 476 raise RuntimeError("Unsupported platform '%s'." % sys.platform) |
| 477 |
| 478 return os.path.join(_REPOSITORY_ROOT, 'buildtools', subdir, exe) |
| 479 |
| 480 |
465 def FindThirdPartyDeps(gn_out_dir, gn_target): | 481 def FindThirdPartyDeps(gn_out_dir, gn_target): |
466 if not gn_out_dir: | 482 if not gn_out_dir: |
467 raise RuntimeError("--gn-out-dir is required if --gn-target is used.") | 483 raise RuntimeError("--gn-out-dir is required if --gn-target is used.") |
468 | 484 |
469 gn_deps = subprocess.check_output(["gn", "desc", gn_out_dir, gn_target, | 485 gn_deps = subprocess.check_output([_GnBinary(), "desc", gn_out_dir, |
| 486 gn_target, |
470 "deps", "--as=buildfile", "--all"]) | 487 "deps", "--as=buildfile", "--all"]) |
471 third_party_deps = set() | 488 third_party_deps = set() |
472 for build_dep in gn_deps.split(): | 489 for build_dep in gn_deps.split(): |
473 if ("third_party" in build_dep and | 490 if ("third_party" in build_dep and |
474 os.path.basename(build_dep) == "BUILD.gn"): | 491 os.path.basename(build_dep) == "BUILD.gn"): |
475 third_party_deps.add(os.path.dirname(build_dep)) | 492 third_party_deps.add(os.path.dirname(build_dep)) |
476 return third_party_deps | 493 return third_party_deps |
477 | 494 |
478 | 495 |
479 def ScanThirdPartyDirs(root=None): | 496 def ScanThirdPartyDirs(root=None): |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 args.output_file, args.target_os, | 631 args.output_file, args.target_os, |
615 args.gn_out_dir, args.gn_target, args.depfile): | 632 args.gn_out_dir, args.gn_target, args.depfile): |
616 return 1 | 633 return 1 |
617 else: | 634 else: |
618 print __doc__ | 635 print __doc__ |
619 return 1 | 636 return 1 |
620 | 637 |
621 | 638 |
622 if __name__ == '__main__': | 639 if __name__ == '__main__': |
623 sys.exit(main()) | 640 sys.exit(main()) |
OLD | NEW |