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 11 matching lines...) Expand all Loading... |
22 import shutil | 22 import shutil |
23 import sys | 23 import sys |
24 import subprocess | 24 import subprocess |
25 import tempfile | 25 import tempfile |
26 import urllib2 | 26 import urllib2 |
27 | 27 |
28 from collections import OrderedDict | 28 from collections import OrderedDict |
29 | 29 |
30 def main(args): | 30 def main(args): |
31 mbw = MetaBuildWrapper() | 31 mbw = MetaBuildWrapper() |
32 mbw.ParseArgs(args) | 32 return mbw.Main(args) |
33 | |
34 try: | |
35 ret = mbw.args.func() | |
36 if ret: | |
37 mbw.DumpInputFiles() | |
38 return ret | |
39 except Exception: | |
40 mbw.DumpInputFiles() | |
41 raise | |
42 | 33 |
43 | 34 |
44 class MetaBuildWrapper(object): | 35 class MetaBuildWrapper(object): |
45 def __init__(self): | 36 def __init__(self): |
46 p = os.path | 37 p = os.path |
47 d = os.path.dirname | 38 d = os.path.dirname |
48 self.chromium_src_dir = p.normpath(d(d(d(p.abspath(__file__))))) | 39 self.chromium_src_dir = p.normpath(d(d(d(p.abspath(__file__))))) |
49 self.default_config = p.join(self.chromium_src_dir, 'tools', 'mb', | 40 self.default_config = p.join(self.chromium_src_dir, 'tools', 'mb', |
50 'mb_config.pyl') | 41 'mb_config.pyl') |
51 self.executable = sys.executable | 42 self.executable = sys.executable |
52 self.platform = sys.platform | 43 self.platform = sys.platform |
53 self.sep = os.sep | 44 self.sep = os.sep |
54 self.args = argparse.Namespace() | 45 self.args = argparse.Namespace() |
55 self.configs = {} | 46 self.configs = {} |
56 self.masters = {} | 47 self.masters = {} |
57 self.mixins = {} | 48 self.mixins = {} |
58 self.private_configs = [] | 49 self.private_configs = [] |
59 self.common_dev_configs = [] | 50 self.common_dev_configs = [] |
60 self.unsupported_configs = [] | 51 self.unsupported_configs = [] |
61 | 52 |
| 53 def Main(self, args): |
| 54 self.ParseArgs(args) |
| 55 try: |
| 56 ret = self.args.func() |
| 57 if ret: |
| 58 self.DumpInputFiles() |
| 59 return ret |
| 60 except KeyboardInterrupt: |
| 61 self.Print('interrupted, exiting', stream=sys.stderr) |
| 62 return 130 |
| 63 except Exception as e: |
| 64 self.DumpInputFiles() |
| 65 self.Print(str(e)) |
| 66 return 1 |
| 67 |
62 def ParseArgs(self, argv): | 68 def ParseArgs(self, argv): |
63 def AddCommonOptions(subp): | 69 def AddCommonOptions(subp): |
64 subp.add_argument('-b', '--builder', | 70 subp.add_argument('-b', '--builder', |
65 help='builder name to look up config from') | 71 help='builder name to look up config from') |
66 subp.add_argument('-m', '--master', | 72 subp.add_argument('-m', '--master', |
67 help='master name to look up config from') | 73 help='master name to look up config from') |
68 subp.add_argument('-c', '--config', | 74 subp.add_argument('-c', '--config', |
69 help='configuration to analyze') | 75 help='configuration to analyze') |
70 subp.add_argument('-f', '--config-file', metavar='PATH', | 76 subp.add_argument('-f', '--config-file', metavar='PATH', |
71 default=self.default_config, | 77 default=self.default_config, |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if not sub_mixin in self.mixins: | 325 if not sub_mixin in self.mixins: |
320 errs.append('Unknown mixin "%s" referenced by mixin "%s".' % | 326 errs.append('Unknown mixin "%s" referenced by mixin "%s".' % |
321 (sub_mixin, mixin)) | 327 (sub_mixin, mixin)) |
322 referenced_mixins.add(sub_mixin) | 328 referenced_mixins.add(sub_mixin) |
323 | 329 |
324 # Check that every mixin defined is actually referenced somewhere. | 330 # Check that every mixin defined is actually referenced somewhere. |
325 for mixin in self.mixins: | 331 for mixin in self.mixins: |
326 if not mixin in referenced_mixins: | 332 if not mixin in referenced_mixins: |
327 errs.append('Unreferenced mixin "%s".' % mixin) | 333 errs.append('Unreferenced mixin "%s".' % mixin) |
328 | 334 |
329 # Check that 'chromium' bots which build public artifacts do not include | 335 # If we're checking the Chromium config, check that the 'chromium' bots |
330 # the chrome_with_codecs 'mixin'. | 336 # which build public artifacts do not include the chrome_with_codecs mixin. |
331 if not 'chromium' in self.masters: | 337 if self.args.config_file == self.default_config: |
332 errs.append('Missing "chromium" master. Please update this proprietary ' | 338 if 'chromium' in self.masters: |
333 'codecs check with the name of the master responsible for ' | 339 for builder in self.masters['chromium']: |
334 'public build artifacts.') | 340 config = self.masters['chromium'][builder] |
335 else: | 341 def RecurseMixins(current_mixin): |
336 for builder in self.masters['chromium']: | 342 if current_mixin == 'chrome_with_codecs': |
337 config = self.masters['chromium'][builder] | 343 errs.append('Public artifact builder "%s" can not contain the ' |
338 def RecurseMixins(current_mixin): | 344 '"chrome_with_codecs" mixin.' % builder) |
339 if current_mixin == 'chrome_with_codecs': | 345 return |
340 errs.append('Public artifact builder "%s" can not contain the ' | 346 if not 'mixins' in self.mixins[current_mixin]: |
341 '"chrome_with_codecs" mixin.' % builder) | 347 return |
342 return | 348 for mixin in self.mixins[current_mixin]['mixins']: |
343 if not 'mixins' in self.mixins[current_mixin]: | 349 RecurseMixins(mixin) |
344 return | 350 |
345 for mixin in self.mixins[current_mixin]['mixins']: | 351 for mixin in self.configs[config]: |
346 RecurseMixins(mixin) | 352 RecurseMixins(mixin) |
347 | 353 else: |
348 for mixin in self.configs[config]: | 354 errs.append('Missing "chromium" master. Please update this ' |
349 RecurseMixins(mixin) | 355 'proprietary codecs check with the name of the master ' |
| 356 'responsible for public build artifacts.') |
350 | 357 |
351 if errs: | 358 if errs: |
352 raise MBErr(('mb config file %s has problems:' % self.args.config_file) + | 359 raise MBErr(('mb config file %s has problems:' % self.args.config_file) + |
353 '\n ' + '\n '.join(errs)) | 360 '\n ' + '\n '.join(errs)) |
354 | 361 |
355 self.Print('mb config file %s looks ok.' % self.args.config_file) | 362 self.Print('mb config file %s looks ok.' % self.args.config_file) |
356 return 0 | 363 return 0 |
357 | 364 |
358 def CmdAudit(self): | 365 def CmdAudit(self): |
359 """Track the progress of the GYP->GN migration on the bots.""" | 366 """Track the progress of the GYP->GN migration on the bots.""" |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 | 1304 |
1298 # Then check to see if the arg contains any metacharacters other than | 1305 # Then check to see if the arg contains any metacharacters other than |
1299 # double quotes; if it does, quote everything (including the double | 1306 # double quotes; if it does, quote everything (including the double |
1300 # quotes) for safety. | 1307 # quotes) for safety. |
1301 if any(a in UNSAFE_FOR_CMD for a in arg): | 1308 if any(a in UNSAFE_FOR_CMD for a in arg): |
1302 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) | 1309 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) |
1303 return arg | 1310 return arg |
1304 | 1311 |
1305 | 1312 |
1306 if __name__ == '__main__': | 1313 if __name__ == '__main__': |
1307 try: | 1314 sys.exit(main(sys.argv[1:])) |
1308 sys.exit(main(sys.argv[1:])) | |
1309 except MBErr as e: | |
1310 print(e) | |
1311 sys.exit(1) | |
1312 except KeyboardInterrupt: | |
1313 print("interrupted, exiting", stream=sys.stderr) | |
1314 sys.exit(130) | |
OLD | NEW |