| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 """MB - the Meta-Build wrapper around GYP and GN | 6 """MB - the Meta-Build wrapper around GYP and GN |
| 7 | 7 |
| 8 MB is a wrapper script for GYP and GN that can be used to generate build files | 8 MB is a wrapper script for GYP and GN that can be used to generate build files |
| 9 for sets of canned configurations and analyze them. | 9 for sets of canned configurations and analyze them. |
| 10 """ | 10 """ |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 return 0 | 422 return 0 |
| 423 | 423 |
| 424 ret = 0 | 424 ret = 0 |
| 425 response_file = self.TempFile() | 425 response_file = self.TempFile() |
| 426 response_file.write('\n'.join(inp['files']) + '\n') | 426 response_file.write('\n'.join(inp['files']) + '\n') |
| 427 response_file.close() | 427 response_file.close() |
| 428 | 428 |
| 429 matching_targets = [] | 429 matching_targets = [] |
| 430 try: | 430 try: |
| 431 cmd = self.GNCmd('refs', self.args.path[0]) + [ | 431 cmd = self.GNCmd('refs', self.args.path[0]) + [ |
| 432 '@%s' % response_file.name, | 432 '@%s' % response_file.name, '--all', '--as=output'] |
| 433 '--type=executable', '--all', '--as=output' | |
| 434 ] | |
| 435 ret, out, _ = self.Run(cmd) | 433 ret, out, _ = self.Run(cmd) |
| 436 if ret and not 'The input matches no targets' in out: | 434 if ret and not 'The input matches no targets' in out: |
| 437 self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out), | 435 self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out), |
| 438 output_path) | 436 output_path) |
| 439 build_dir = self.ToSrcRelPath(self.args.path[0]) + os.sep | 437 build_dir = self.ToSrcRelPath(self.args.path[0]) + os.sep |
| 440 for output in out.splitlines(): | 438 for output in out.splitlines(): |
| 441 build_output = output.replace(build_dir, '') | 439 build_output = output.replace(build_dir, '') |
| 442 if build_output in inp['targets']: | 440 if build_output in inp['targets']: |
| 443 matching_targets.append(build_output) | 441 matching_targets.append(build_output) |
| 442 |
| 443 cmd = self.GNCmd('refs', self.args.path[0]) + [ |
| 444 '@%s' % response_file.name, '--all'] |
| 445 ret, out, _ = self.Run(cmd) |
| 446 if ret and not 'The input matches no targets' in out: |
| 447 self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out), |
| 448 output_path) |
| 449 for label in out.splitlines(): |
| 450 build_target = label[2:] |
| 451 # We want to accept 'chrome/android:chrome_shell_apk' and |
| 452 # just 'chrome_shell_apk'. This may result in too many targets |
| 453 # getting built, but we can adjust that later if need be. |
| 454 for input_target in inp['targets']: |
| 455 if (input_target == build_target or |
| 456 build_target.endswith(':' + input_target)): |
| 457 matching_targets.append(input_target) |
| 444 finally: | 458 finally: |
| 445 self.RemoveFile(response_file.name) | 459 self.RemoveFile(response_file.name) |
| 446 | 460 |
| 447 if matching_targets: | 461 if matching_targets: |
| 448 # TODO: it could be that a target X might depend on a target Y | 462 # TODO: it could be that a target X might depend on a target Y |
| 449 # and both would be listed in the input, but we would only need | 463 # and both would be listed in the input, but we would only need |
| 450 # to specify target X as a build_target (whereas both X and Y are | 464 # to specify target X as a build_target (whereas both X and Y are |
| 451 # targets). I'm not sure if that optimization is generally worth it. | 465 # targets). I'm not sure if that optimization is generally worth it. |
| 452 self.WriteJSON({'targets': sorted(matching_targets), | 466 self.WriteJSON({'targets': sorted(matching_targets), |
| 453 'build_targets': sorted(matching_targets), | 467 'build_targets': sorted(matching_targets), |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 | 576 |
| 563 if __name__ == '__main__': | 577 if __name__ == '__main__': |
| 564 try: | 578 try: |
| 565 sys.exit(main(sys.argv[1:])) | 579 sys.exit(main(sys.argv[1:])) |
| 566 except MBErr as e: | 580 except MBErr as e: |
| 567 print(e) | 581 print(e) |
| 568 sys.exit(1) | 582 sys.exit(1) |
| 569 except KeyboardInterrupt: | 583 except KeyboardInterrupt: |
| 570 print("interrupted, exiting", stream=sys.stderr) | 584 print("interrupted, exiting", stream=sys.stderr) |
| 571 sys.exit(130) | 585 sys.exit(130) |
| OLD | NEW |