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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 name = fields[0] | 337 name = fields[0] |
338 val = ' '.join(fields[2:]) | 338 val = ' '.join(fields[2:]) |
339 gn_args.append('%s=%s' % (name, val)) | 339 gn_args.append('%s=%s' % (name, val)) |
340 | 340 |
341 return { | 341 return { |
342 'gn_args': ' '.join(gn_args), | 342 'gn_args': ' '.join(gn_args), |
343 'type': 'gn', | 343 'type': 'gn', |
344 } | 344 } |
345 | 345 |
346 def Lookup(self): | 346 def Lookup(self): |
347 self.ReadConfigFile() | 347 vals = self.ReadBotConfig() |
348 config = self.ConfigFromArgs() | 348 if not vals: |
349 if not config in self.configs: | 349 self.ReadConfigFile() |
350 raise MBErr('Config "%s" not found in %s' % | 350 config = self.ConfigFromArgs() |
351 (config, self.args.config_file)) | 351 if not config in self.configs: |
352 raise MBErr('Config "%s" not found in %s' % | |
353 (config, self.args.config_file)) | |
352 | 354 |
353 vals = self.FlattenConfig(config) | 355 vals = self.FlattenConfig(config) |
354 | 356 |
355 # Do some basic sanity checking on the config so that we | 357 # Do some basic sanity checking on the config so that we |
356 # don't have to do this in every caller. | 358 # don't have to do this in every caller. |
357 assert 'type' in vals, 'No meta-build type specified in the config' | 359 assert 'type' in vals, 'No meta-build type specified in the config' |
358 assert vals['type'] in ('gn', 'gyp'), ( | 360 assert vals['type'] in ('gn', 'gyp'), ( |
359 'Unknown meta-build type "%s"' % vals['gn_args']) | 361 'Unknown meta-build type "%s"' % vals['gn_args']) |
360 | 362 |
361 return vals | 363 return vals |
362 | 364 |
365 def ReadBotConfig(self): | |
366 if not self.args.master or not self.args.builder: | |
367 return {} | |
368 path = self.PathJoin(self.chromium_src_dir, 'ios', 'build', 'bots', | |
369 self.args.master, | |
370 self.args.builder.replace(' ', '_') + '.json') | |
smut
2015/11/18 22:00:29
Shouldn't need this. The recipes read the builder
Dirk Pranke
2015/11/18 22:30:27
Ah, you're right. That's an unorthodox naming sche
| |
371 if not self.Exists(path): | |
372 return {} | |
373 | |
374 contents = json.loads(self.ReadFile(path)) | |
375 gyp_vals = contents.get('GYP_DEFINES', {}) | |
376 if isinstance(gyp_vals, dict): | |
377 gyp_defines = ' '.join('%s=%s' % (k, v) for k, v in gyp_vals.items()) | |
378 else: | |
379 gyp_defines = ' '.join(gyp_vals) | |
380 gn_args = ' '.join(contents.get('gn_args', [])) | |
381 | |
382 return { | |
383 'type': contents.get('mb_type', ''), | |
384 'gn_args': gn_args, | |
385 'gyp_defines': gyp_defines, | |
386 } | |
387 | |
363 def ReadConfigFile(self): | 388 def ReadConfigFile(self): |
364 if not self.Exists(self.args.config_file): | 389 if not self.Exists(self.args.config_file): |
365 raise MBErr('config file not found at %s' % self.args.config_file) | 390 raise MBErr('config file not found at %s' % self.args.config_file) |
366 | 391 |
367 try: | 392 try: |
368 contents = ast.literal_eval(self.ReadFile(self.args.config_file)) | 393 contents = ast.literal_eval(self.ReadFile(self.args.config_file)) |
369 except SyntaxError as e: | 394 except SyntaxError as e: |
370 raise MBErr('Failed to parse config file "%s": %s' % | 395 raise MBErr('Failed to parse config file "%s": %s' % |
371 (self.args.config_file, e)) | 396 (self.args.config_file, e)) |
372 | 397 |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 | 1115 |
1091 if __name__ == '__main__': | 1116 if __name__ == '__main__': |
1092 try: | 1117 try: |
1093 sys.exit(main(sys.argv[1:])) | 1118 sys.exit(main(sys.argv[1:])) |
1094 except MBErr as e: | 1119 except MBErr as e: |
1095 print(e) | 1120 print(e) |
1096 sys.exit(1) | 1121 sys.exit(1) |
1097 except KeyboardInterrupt: | 1122 except KeyboardInterrupt: |
1098 print("interrupted, exiting", stream=sys.stderr) | 1123 print("interrupted, exiting", stream=sys.stderr) |
1099 sys.exit(130) | 1124 sys.exit(130) |
OLD | NEW |