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 28 matching lines...) Expand all Loading... |
39 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__))))) |
40 self.default_config = p.join(self.chromium_src_dir, 'tools', 'mb', | 40 self.default_config = p.join(self.chromium_src_dir, 'tools', 'mb', |
41 'mb_config.pyl') | 41 'mb_config.pyl') |
42 self.executable = sys.executable | 42 self.executable = sys.executable |
43 self.platform = sys.platform | 43 self.platform = sys.platform |
44 self.sep = os.sep | 44 self.sep = os.sep |
45 self.args = argparse.Namespace() | 45 self.args = argparse.Namespace() |
46 self.configs = {} | 46 self.configs = {} |
47 self.masters = {} | 47 self.masters = {} |
48 self.mixins = {} | 48 self.mixins = {} |
49 self.private_configs = [] | |
50 self.common_dev_configs = [] | |
51 self.unsupported_configs = [] | |
52 | 49 |
53 def Main(self, args): | 50 def Main(self, args): |
54 self.ParseArgs(args) | 51 self.ParseArgs(args) |
55 try: | 52 try: |
56 ret = self.args.func() | 53 ret = self.args.func() |
57 if ret: | 54 if ret: |
58 self.DumpInputFiles() | 55 self.DumpInputFiles() |
59 return ret | 56 return ret |
60 except KeyboardInterrupt: | 57 except KeyboardInterrupt: |
61 self.Print('interrupted, exiting', stream=sys.stderr) | 58 self.Print('interrupted, exiting', stream=sys.stderr) |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 force_verbose=False, buffer_output=False) | 262 force_verbose=False, buffer_output=False) |
266 | 263 |
267 return ret | 264 return ret |
268 | 265 |
269 def CmdValidate(self): | 266 def CmdValidate(self): |
270 errs = [] | 267 errs = [] |
271 | 268 |
272 # Read the file to make sure it parses. | 269 # Read the file to make sure it parses. |
273 self.ReadConfigFile() | 270 self.ReadConfigFile() |
274 | 271 |
275 # Figure out the whole list of configs and ensure that no config is | 272 # Build a list of all of the configs referenced by builders. |
276 # listed in more than one category. | |
277 all_configs = {} | 273 all_configs = {} |
278 for config in self.common_dev_configs: | |
279 all_configs[config] = 'common_dev_configs' | |
280 for config in self.private_configs: | |
281 if config in all_configs: | |
282 errs.append('config "%s" listed in "private_configs" also ' | |
283 'listed in "%s"' % (config, all_configs['config'])) | |
284 else: | |
285 all_configs[config] = 'private_configs' | |
286 for config in self.unsupported_configs: | |
287 if config in all_configs: | |
288 errs.append('config "%s" listed in "unsupported_configs" also ' | |
289 'listed in "%s"' % (config, all_configs['config'])) | |
290 else: | |
291 all_configs[config] = 'unsupported_configs' | |
292 | |
293 for master in self.masters: | 274 for master in self.masters: |
294 for builder in self.masters[master]: | 275 for config in self.masters[master].values(): |
295 config = self.masters[master][builder] | 276 all_configs[config] = master |
296 if config in all_configs and all_configs[config] not in self.masters: | |
297 errs.append('Config "%s" used by a bot is also listed in "%s".' % | |
298 (config, all_configs[config])) | |
299 else: | |
300 all_configs[config] = master | |
301 | 277 |
302 # Check that every referenced config actually exists. | 278 # Check that every referenced config actually exists. |
303 for config, loc in all_configs.items(): | 279 for config, loc in all_configs.items(): |
304 if not config in self.configs: | 280 if not config in self.configs: |
305 errs.append('Unknown config "%s" referenced from "%s".' % | 281 errs.append('Unknown config "%s" referenced from "%s".' % |
306 (config, loc)) | 282 (config, loc)) |
307 | 283 |
308 # Check that every actual config is actually referenced. | 284 # Check that every actual config is actually referenced. |
309 for config in self.configs: | 285 for config in self.configs: |
310 if not config in all_configs: | 286 if not config in all_configs: |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 def ReadConfigFile(self): | 537 def ReadConfigFile(self): |
562 if not self.Exists(self.args.config_file): | 538 if not self.Exists(self.args.config_file): |
563 raise MBErr('config file not found at %s' % self.args.config_file) | 539 raise MBErr('config file not found at %s' % self.args.config_file) |
564 | 540 |
565 try: | 541 try: |
566 contents = ast.literal_eval(self.ReadFile(self.args.config_file)) | 542 contents = ast.literal_eval(self.ReadFile(self.args.config_file)) |
567 except SyntaxError as e: | 543 except SyntaxError as e: |
568 raise MBErr('Failed to parse config file "%s": %s' % | 544 raise MBErr('Failed to parse config file "%s": %s' % |
569 (self.args.config_file, e)) | 545 (self.args.config_file, e)) |
570 | 546 |
571 self.common_dev_configs = contents['common_dev_configs'] | |
572 self.configs = contents['configs'] | 547 self.configs = contents['configs'] |
573 self.masters = contents['masters'] | 548 self.masters = contents['masters'] |
574 self.mixins = contents['mixins'] | 549 self.mixins = contents['mixins'] |
575 self.private_configs = contents['private_configs'] | |
576 self.unsupported_configs = contents['unsupported_configs'] | |
577 | 550 |
578 def ConfigFromArgs(self): | 551 def ConfigFromArgs(self): |
579 if self.args.config: | 552 if self.args.config: |
580 if self.args.master or self.args.builder: | 553 if self.args.master or self.args.builder: |
581 raise MBErr('Can not specific both -c/--config and -m/--master or ' | 554 raise MBErr('Can not specific both -c/--config and -m/--master or ' |
582 '-b/--builder') | 555 '-b/--builder') |
583 | 556 |
584 return self.args.config | 557 return self.args.config |
585 | 558 |
586 if not self.args.master or not self.args.builder: | 559 if not self.args.master or not self.args.builder: |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 # Then check to see if the arg contains any metacharacters other than | 1278 # Then check to see if the arg contains any metacharacters other than |
1306 # double quotes; if it does, quote everything (including the double | 1279 # double quotes; if it does, quote everything (including the double |
1307 # quotes) for safety. | 1280 # quotes) for safety. |
1308 if any(a in UNSAFE_FOR_CMD for a in arg): | 1281 if any(a in UNSAFE_FOR_CMD for a in arg): |
1309 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) | 1282 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) |
1310 return arg | 1283 return arg |
1311 | 1284 |
1312 | 1285 |
1313 if __name__ == '__main__': | 1286 if __name__ == '__main__': |
1314 sys.exit(main(sys.argv[1:])) | 1287 sys.exit(main(sys.argv[1:])) |
OLD | NEW |