| 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 return vals | 519 return vals |
| 520 | 520 |
| 521 # TODO: We can only get the config for GN build dirs, not GYP build dirs. | 521 # TODO: We can only get the config for GN build dirs, not GYP build dirs. |
| 522 # GN stores the args that were used in args.gn in the build dir, | 522 # GN stores the args that were used in args.gn in the build dir, |
| 523 # but GYP doesn't store them anywhere. We should consider modifying | 523 # but GYP doesn't store them anywhere. We should consider modifying |
| 524 # gyp_chromium to record the arguments it runs with in a similar | 524 # gyp_chromium to record the arguments it runs with in a similar |
| 525 # manner. | 525 # manner. |
| 526 | 526 |
| 527 mb_type_path = self.PathJoin(self.ToAbsPath(build_dir), 'mb_type') | 527 mb_type_path = self.PathJoin(self.ToAbsPath(build_dir), 'mb_type') |
| 528 if not self.Exists(mb_type_path): | 528 if not self.Exists(mb_type_path): |
| 529 gn_args_path = self.PathJoin(self.ToAbsPath(build_dir), 'args.gn') | 529 toolchain_path = self.PathJoin(self.ToAbsPath(build_dir), |
| 530 if not self.Exists(gn_args_path): | 530 'toolchain.ninja') |
| 531 if not self.Exists(toolchain_path): |
| 531 self.Print('Must either specify a path to an existing GN build dir ' | 532 self.Print('Must either specify a path to an existing GN build dir ' |
| 532 'or pass in a -m/-b pair or a -c flag to specify the ' | 533 'or pass in a -m/-b pair or a -c flag to specify the ' |
| 533 'configuration') | 534 'configuration') |
| 534 return {} | 535 return {} |
| 535 else: | 536 else: |
| 536 mb_type = 'gn' | 537 mb_type = 'gn' |
| 537 else: | 538 else: |
| 538 mb_type = self.ReadFile(mb_type_path).strip() | 539 mb_type = self.ReadFile(mb_type_path).strip() |
| 539 | 540 |
| 540 if mb_type == 'gn': | 541 if mb_type == 'gn': |
| 541 vals = self.GNValsFromDir(build_dir) | 542 vals = self.GNValsFromDir(build_dir) |
| 542 else: | 543 else: |
| 543 vals = {} | 544 vals = {} |
| 544 vals['type'] = mb_type | 545 vals['type'] = mb_type |
| 545 | 546 |
| 546 return vals | 547 return vals |
| 547 | 548 |
| 548 def GNValsFromDir(self, build_dir): | 549 def GNValsFromDir(self, build_dir): |
| 549 args_contents = self.ReadFile( | 550 args_contents = "" |
| 550 self.PathJoin(self.ToAbsPath(build_dir), 'args.gn')) | 551 gn_args_path = self.PathJoin(self.ToAbsPath(build_dir), 'args.gn') |
| 552 if self.Exists(gn_args_path): |
| 553 args_contents = self.ReadFile(gn_args_path) |
| 551 gn_args = [] | 554 gn_args = [] |
| 552 for l in args_contents.splitlines(): | 555 for l in args_contents.splitlines(): |
| 553 fields = l.split(' ') | 556 fields = l.split(' ') |
| 554 name = fields[0] | 557 name = fields[0] |
| 555 val = ' '.join(fields[2:]) | 558 val = ' '.join(fields[2:]) |
| 556 gn_args.append('%s=%s' % (name, val)) | 559 gn_args.append('%s=%s' % (name, val)) |
| 557 | 560 |
| 558 return { | 561 return { |
| 559 'gn_args': ' '.join(gn_args), | 562 'gn_args': ' '.join(gn_args), |
| 560 'type': 'gn', | 563 'type': 'gn', |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 # Then check to see if the arg contains any metacharacters other than | 1469 # Then check to see if the arg contains any metacharacters other than |
| 1467 # double quotes; if it does, quote everything (including the double | 1470 # double quotes; if it does, quote everything (including the double |
| 1468 # quotes) for safety. | 1471 # quotes) for safety. |
| 1469 if any(a in UNSAFE_FOR_CMD for a in arg): | 1472 if any(a in UNSAFE_FOR_CMD for a in arg): |
| 1470 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) | 1473 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) |
| 1471 return arg | 1474 return arg |
| 1472 | 1475 |
| 1473 | 1476 |
| 1474 if __name__ == '__main__': | 1477 if __name__ == '__main__': |
| 1475 sys.exit(main(sys.argv[1:])) | 1478 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |