Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: tools/mb/mb.py

Issue 1411183010: Make MB aware of iOS bot configs and get iOS working. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to #360460, clean up Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/mb/docs/user_guide.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, self.args.builder + '.json')
370 if not self.Exists(path):
371 return {}
372
373 contents = json.loads(self.ReadFile(path))
374 gyp_vals = contents.get('GYP_DEFINES', {})
375 if isinstance(gyp_vals, dict):
376 gyp_defines = ' '.join('%s=%s' % (k, v) for k, v in gyp_vals.items())
377 else:
378 gyp_defines = ' '.join(gyp_vals)
379 gn_args = ' '.join(contents.get('gn_args', []))
380
381 return {
382 'type': contents.get('mb_type', ''),
383 'gn_args': gn_args,
384 'gyp_defines': gyp_defines,
385 }
386
363 def ReadConfigFile(self): 387 def ReadConfigFile(self):
364 if not self.Exists(self.args.config_file): 388 if not self.Exists(self.args.config_file):
365 raise MBErr('config file not found at %s' % self.args.config_file) 389 raise MBErr('config file not found at %s' % self.args.config_file)
366 390
367 try: 391 try:
368 contents = ast.literal_eval(self.ReadFile(self.args.config_file)) 392 contents = ast.literal_eval(self.ReadFile(self.args.config_file))
369 except SyntaxError as e: 393 except SyntaxError as e:
370 raise MBErr('Failed to parse config file "%s": %s' % 394 raise MBErr('Failed to parse config file "%s": %s' %
371 (self.args.config_file, e)) 395 (self.args.config_file, e))
372 396
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1114
1091 if __name__ == '__main__': 1115 if __name__ == '__main__':
1092 try: 1116 try:
1093 sys.exit(main(sys.argv[1:])) 1117 sys.exit(main(sys.argv[1:]))
1094 except MBErr as e: 1118 except MBErr as e:
1095 print(e) 1119 print(e)
1096 sys.exit(1) 1120 sys.exit(1)
1097 except KeyboardInterrupt: 1121 except KeyboardInterrupt:
1098 print("interrupted, exiting", stream=sys.stderr) 1122 print("interrupted, exiting", stream=sys.stderr)
1099 sys.exit(130) 1123 sys.exit(130)
OLDNEW
« no previous file with comments | « tools/mb/docs/user_guide.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698