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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 if 'gn_all' in inp['targets'] or 'all' in inp['targets']: | 423 if 'gn_all' in inp['targets'] or 'all' in inp['targets']: |
424 self.WriteJSON({'status': 'Found dependency (all)'}, output_path) | 424 self.WriteJSON({'status': 'Found dependency (all)'}, output_path) |
425 return 0 | 425 return 0 |
426 | 426 |
427 all_needed_targets = set() | 427 all_needed_targets = set() |
428 ret = 0 | 428 ret = 0 |
429 for f in inp['files']: | 429 for f in inp['files']: |
430 cmd = self.GNCmd('refs', self.args.path[0]) + [ | 430 cmd = self.GNCmd('refs', self.args.path[0]) + [ |
431 '//' + f, '--type=executable', '--all', '--as=output'] | 431 '//' + f, '--type=executable', '--all', '--as=output'] |
432 ret, out, _ = self.Run(cmd) | 432 ret, out, _ = self.Run(cmd) |
433 if ret: | 433 if ret and not 'The input matches no targets' in out: |
434 self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out), | 434 self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out), |
435 output_path) | 435 output_path) |
436 | 436 |
437 rpath = self.ToSrcRelPath(self.args.path[0]) + os.sep | 437 rpath = self.ToSrcRelPath(self.args.path[0]) + os.sep |
438 needed_targets = [t.replace(rpath, '') for t in out.splitlines()] | 438 needed_targets = [t.replace(rpath, '') for t in out.splitlines()] |
439 needed_targets = [nt for nt in needed_targets if nt in inp['targets']] | 439 needed_targets = [nt for nt in needed_targets if nt in inp['targets']] |
440 all_needed_targets.update(set(needed_targets)) | 440 all_needed_targets.update(set(needed_targets)) |
441 | 441 |
442 if all_needed_targets: | 442 if all_needed_targets: |
443 # TODO: it could be that a target X might depend on a target Y | 443 # TODO: it could be that a target X might depend on a target Y |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 548 |
549 if __name__ == '__main__': | 549 if __name__ == '__main__': |
550 try: | 550 try: |
551 sys.exit(main(sys.argv[1:])) | 551 sys.exit(main(sys.argv[1:])) |
552 except MBErr as e: | 552 except MBErr as e: |
553 print(e) | 553 print(e) |
554 sys.exit(1) | 554 sys.exit(1) |
555 except KeyboardInterrupt: | 555 except KeyboardInterrupt: |
556 print("interrupted, exiting", stream=sys.stderr) | 556 print("interrupted, exiting", stream=sys.stderr) |
557 sys.exit(130) | 557 sys.exit(130) |
OLD | NEW |