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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 help='path to a file containing the input arguments ' | 82 help='path to a file containing the input arguments ' |
83 'as a JSON object.') | 83 'as a JSON object.') |
84 subp.add_argument('output_path', nargs=1, | 84 subp.add_argument('output_path', nargs=1, |
85 help='path to a file containing the output arguments ' | 85 help='path to a file containing the output arguments ' |
86 'as a JSON object.') | 86 'as a JSON object.') |
87 subp.set_defaults(func=self.CmdAnalyze) | 87 subp.set_defaults(func=self.CmdAnalyze) |
88 | 88 |
89 subp = subps.add_parser('gen', | 89 subp = subps.add_parser('gen', |
90 help='generate a new set of build files') | 90 help='generate a new set of build files') |
91 AddCommonOptions(subp) | 91 AddCommonOptions(subp) |
92 subp.add_argument('--swarming-targets', | |
93 help='save runtime dependencies for targets in file ' | |
94 '(GN only).') | |
92 subp.add_argument('path', nargs=1, | 95 subp.add_argument('path', nargs=1, |
93 help='path to generate build into') | 96 help='path to generate build into') |
94 subp.set_defaults(func=self.CmdGen) | 97 subp.set_defaults(func=self.CmdGen) |
95 | 98 |
96 subp = subps.add_parser('isolate', | 99 subp = subps.add_parser('isolate', |
97 help='build isolates') | 100 help='build isolates') |
98 AddCommonOptions(subp) | 101 AddCommonOptions(subp) |
99 subp.add_argument('path', nargs=1, | 102 subp.add_argument('path', nargs=1, |
100 help='path build was generated into.') | 103 help='path build was generated into.') |
101 subp.add_argument('input_path', nargs=1, | 104 subp.add_argument('input_path', nargs=1, |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 if vals['gyp_defines']: | 332 if vals['gyp_defines']: |
330 vals['gyp_defines'] += ' ' + mixin_vals['gyp_defines'] | 333 vals['gyp_defines'] += ' ' + mixin_vals['gyp_defines'] |
331 else: | 334 else: |
332 vals['gyp_defines'] = mixin_vals['gyp_defines'] | 335 vals['gyp_defines'] = mixin_vals['gyp_defines'] |
333 if 'mixins' in mixin_vals: | 336 if 'mixins' in mixin_vals: |
334 self.FlattenMixins(mixin_vals['mixins'], vals, visited) | 337 self.FlattenMixins(mixin_vals['mixins'], vals, visited) |
335 return vals | 338 return vals |
336 | 339 |
337 def RunGNGen(self, path, vals): | 340 def RunGNGen(self, path, vals): |
338 cmd = self.GNCmd('gen', path, vals['gn_args']) | 341 cmd = self.GNCmd('gen', path, vals['gn_args']) |
342 | |
343 if self.args.swarming_targets: | |
344 # We need GN to generate the list of runtime dependencies for | |
345 # the compile targets listed (one per line) in the file so | |
346 # we can run them via swarming. We use ninja_to_gn.pyl to convert | |
347 # the compile targets to the matching GN labels. | |
348 contents = self.ReadFile(self.args.swarming_targets) | |
349 runtime_deps_targets = contents.splitlines() | |
350 ninja_targets_to_labels = ast.literal_eval(self.ReadFile(os.path.join( | |
M-A Ruel
2015/06/10 14:53:40
I trick we used in isolate Go is to pre-process th
Dirk Pranke
2015/06/10 16:07:59
That is a good suggestion, but since .pyl / ast.li
| |
351 self.chromium_src_dir, 'testing', 'buildbot', 'ninja_to_gn.pyl'))) | |
352 gn_labels = [] | |
353 for target in runtime_deps_targets: | |
354 if not target in ninja_targets_to_label: | |
355 raise MBErr('test target "%s" not found in %s' % | |
356 (target, "//testing/buildbot/ninja_to_gn.pyl")) | |
M-A Ruel
2015/06/10 14:53:40
Use single quotes
Dirk Pranke
2015/06/10 16:07:59
will fix.
| |
357 | |
358 gn_runtime_deps_path = self.ToAbsPath(os.path.join(path, | |
359 'runtime_deps')) | |
360 self.WriteFile(gn_runtime_deps_path, '\n'.join(gn_labels) + '\n') | |
361 cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path) | |
M-A Ruel
2015/06/10 14:53:40
use two separate args, it works better on Windows.
Dirk Pranke
2015/06/10 16:07:59
I can't; GN only supports --foo=bar style argument
| |
362 | |
339 ret, _, _ = self.Run(cmd) | 363 ret, _, _ = self.Run(cmd) |
364 | |
365 if self.args.swarming_targets: | |
366 for target in swarming_targets: | |
M-A Ruel
2015/06/10 14:53:40
Where is this variable defined? I don't see how th
Dirk Pranke
2015/06/10 16:07:59
Whoops, you're right. This should be looping over
| |
367 output = os.path.join(path, target + '.runtime_deps') | |
368 deps_path = self.ToAbsPath(os.path.join(path, | |
369 target + '.runtime_deps')) | |
370 if not self.Exists(self.ToAbsPath(output)): | |
371 raise MBErr('did not generate %s' % output) | |
372 | |
340 return ret | 373 return ret |
341 | 374 |
342 def GNCmd(self, subcommand, path, gn_args=''): | 375 def GNCmd(self, subcommand, path, gn_args=''): |
343 if self.platform == 'linux2': | 376 if self.platform == 'linux2': |
344 gn_path = os.path.join(self.chromium_src_dir, 'buildtools', 'linux64', | 377 gn_path = os.path.join(self.chromium_src_dir, 'buildtools', 'linux64', |
345 'gn') | 378 'gn') |
346 elif self.platform == 'darwin': | 379 elif self.platform == 'darwin': |
347 gn_path = os.path.join(self.chromium_src_dir, 'buildtools', 'mac', | 380 gn_path = os.path.join(self.chromium_src_dir, 'buildtools', 'mac', |
348 'gn') | 381 'gn') |
349 else: | 382 else: |
(...skipping 30 matching lines...) Expand all Loading... | |
380 self.Print() | 413 self.Print() |
381 | 414 |
382 cmd = self.GYPCmd(output_dir, vals['gyp_defines'], config=gyp_config) | 415 cmd = self.GYPCmd(output_dir, vals['gyp_defines'], config=gyp_config) |
383 cmd.extend(['-G', 'config_path=%s' % self.args.input_path[0], | 416 cmd.extend(['-G', 'config_path=%s' % self.args.input_path[0], |
384 '-G', 'analyzer_output_path=%s' % self.args.output_path[0]]) | 417 '-G', 'analyzer_output_path=%s' % self.args.output_path[0]]) |
385 ret, _, _ = self.Run(cmd) | 418 ret, _, _ = self.Run(cmd) |
386 if not ret and self.args.verbose: | 419 if not ret and self.args.verbose: |
387 outp = json.loads(self.ReadFile(self.args.output_path[0])) | 420 outp = json.loads(self.ReadFile(self.args.output_path[0])) |
388 self.Print() | 421 self.Print() |
389 self.Print('analyze output:') | 422 self.Print('analyze output:') |
390 self.PrintJSON(inp) | 423 self.PrintJSON(outp) |
Dirk Pranke
2015/06/10 06:43:17
this is an unrelated bug that pylint revealed :).
| |
391 self.Print() | 424 self.Print() |
392 | 425 |
393 return ret | 426 return ret |
394 | 427 |
395 def RunGNIsolate(self, vals): | 428 def RunGNIsolate(self, vals): |
396 build_path = self.args.path[0] | 429 build_path = self.args.path[0] |
397 inp = self.ReadInputJSON(['targets']) | 430 inp = self.ReadInputJSON(['targets']) |
398 if self.args.verbose: | 431 if self.args.verbose: |
399 self.Print() | 432 self.Print() |
400 self.Print('isolate input:') | 433 self.Print('isolate input:') |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
717 | 750 |
718 if __name__ == '__main__': | 751 if __name__ == '__main__': |
719 try: | 752 try: |
720 sys.exit(main(sys.argv[1:])) | 753 sys.exit(main(sys.argv[1:])) |
721 except MBErr as e: | 754 except MBErr as e: |
722 print(e) | 755 print(e) |
723 sys.exit(1) | 756 sys.exit(1) |
724 except KeyboardInterrupt: | 757 except KeyboardInterrupt: |
725 print("interrupted, exiting", stream=sys.stderr) | 758 print("interrupted, exiting", stream=sys.stderr) |
726 sys.exit(130) | 759 sys.exit(130) |
OLD | NEW |