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

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

Issue 1881823002: Support references to args files in MB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mb_write_args_file
Patch Set: fix indent Created 4 years, 8 months 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 | « build/args/bots/official.desktop/blimp-engine.gn ('k') | tools/mb/mb_config.pyl » ('j') | 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 # Read the file to make sure it parses. 311 # Read the file to make sure it parses.
312 self.ReadConfigFile() 312 self.ReadConfigFile()
313 313
314 # Build a list of all of the configs referenced by builders. 314 # Build a list of all of the configs referenced by builders.
315 all_configs = {} 315 all_configs = {}
316 for master in self.masters: 316 for master in self.masters:
317 for config in self.masters[master].values(): 317 for config in self.masters[master].values():
318 all_configs[config] = master 318 all_configs[config] = master
319 319
320 # Check that every referenced config actually exists. 320 # Check that every referenced args file or config actually exists.
321 for config, loc in all_configs.items(): 321 for config, loc in all_configs.items():
322 if not config in self.configs: 322 if config.startswith('//'):
323 if not self.Exists(self.ToAbsPath(config)):
324 errs.append('Unknown args file "%s" referenced from "%s".' %
325 (config, loc))
326 elif not config in self.configs:
323 errs.append('Unknown config "%s" referenced from "%s".' % 327 errs.append('Unknown config "%s" referenced from "%s".' %
324 (config, loc)) 328 (config, loc))
325 329
326 # Check that every actual config is actually referenced. 330 # Check that every actual config is actually referenced.
327 for config in self.configs: 331 for config in self.configs:
328 if not config in all_configs: 332 if not config in all_configs:
329 errs.append('Unused config "%s".' % config) 333 errs.append('Unused config "%s".' % config)
330 334
331 # Figure out the whole list of mixins, and check that every mixin 335 # Figure out the whole list of mixins, and check that every mixin
332 # listed by a config or another mixin actually exists. 336 # listed by a config or another mixin actually exists.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 return { 547 return {
544 'gn_args': ' '.join(gn_args), 548 'gn_args': ' '.join(gn_args),
545 'type': 'gn', 549 'type': 'gn',
546 } 550 }
547 551
548 def Lookup(self): 552 def Lookup(self):
549 vals = self.ReadBotConfig() 553 vals = self.ReadBotConfig()
550 if not vals: 554 if not vals:
551 self.ReadConfigFile() 555 self.ReadConfigFile()
552 config = self.ConfigFromArgs() 556 config = self.ConfigFromArgs()
553 if not config in self.configs: 557 if config.startswith('//'):
554 raise MBErr('Config "%s" not found in %s' % 558 if not self.Exists(self.ToAbsPath(config)):
555 (config, self.args.config_file)) 559 raise MBErr('args file "%s" not found' % config)
556 560 vals = {
557 vals = self.FlattenConfig(config) 561 'type': 'gn',
562 'args_file': config,
563 'gn_args': '',
564 }
565 else:
566 if not config in self.configs:
567 raise MBErr('Config "%s" not found in %s' %
568 (config, self.args.config_file))
569 vals = self.FlattenConfig(config)
558 570
559 # Do some basic sanity checking on the config so that we 571 # Do some basic sanity checking on the config so that we
560 # don't have to do this in every caller. 572 # don't have to do this in every caller.
561 assert 'type' in vals, 'No meta-build type specified in the config' 573 assert 'type' in vals, 'No meta-build type specified in the config'
562 assert vals['type'] in ('gn', 'gyp'), ( 574 assert vals['type'] in ('gn', 'gyp'), (
563 'Unknown meta-build type "%s"' % vals['gn_args']) 575 'Unknown meta-build type "%s"' % vals['gn_args'])
564 576
565 return vals 577 return vals
566 578
567 def ReadBotConfig(self): 579 def ReadBotConfig(self):
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 def GNArgs(self, vals): 878 def GNArgs(self, vals):
867 gn_args = vals['gn_args'] 879 gn_args = vals['gn_args']
868 if self.args.goma_dir: 880 if self.args.goma_dir:
869 gn_args += ' goma_dir="%s"' % self.args.goma_dir 881 gn_args += ' goma_dir="%s"' % self.args.goma_dir
870 882
871 # Canonicalize the arg string into a sorted, newline-separated list 883 # Canonicalize the arg string into a sorted, newline-separated list
872 # of key-value pairs, and de-dup the keys if need be so that only 884 # of key-value pairs, and de-dup the keys if need be so that only
873 # the last instance of each arg is listed. 885 # the last instance of each arg is listed.
874 gn_args = gn_helpers.ToGNString(gn_helpers.FromGNArgs(gn_args)) 886 gn_args = gn_helpers.ToGNString(gn_helpers.FromGNArgs(gn_args))
875 887
888 args_file = vals.get('args_file', None)
889 if args_file:
890 gn_args = ('import("%s")\n' % vals['args_file']) + gn_args
876 return gn_args 891 return gn_args
877 892
878 def RunGYPGen(self, vals): 893 def RunGYPGen(self, vals):
879 path = self.args.path[0] 894 path = self.args.path[0]
880 895
881 output_dir = self.ParseGYPConfigPath(path) 896 output_dir = self.ParseGYPConfigPath(path)
882 cmd, env = self.GYPCmd(output_dir, vals) 897 cmd, env = self.GYPCmd(output_dir, vals)
883 ret, _, _ = self.Run(cmd, env=env) 898 ret, _, _ = self.Run(cmd, env=env)
884 return ret 899 return ret
885 900
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 # Then check to see if the arg contains any metacharacters other than 1390 # Then check to see if the arg contains any metacharacters other than
1376 # double quotes; if it does, quote everything (including the double 1391 # double quotes; if it does, quote everything (including the double
1377 # quotes) for safety. 1392 # quotes) for safety.
1378 if any(a in UNSAFE_FOR_CMD for a in arg): 1393 if any(a in UNSAFE_FOR_CMD for a in arg):
1379 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) 1394 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg)
1380 return arg 1395 return arg
1381 1396
1382 1397
1383 if __name__ == '__main__': 1398 if __name__ == '__main__':
1384 sys.exit(main(sys.argv[1:])) 1399 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « build/args/bots/official.desktop/blimp-engine.gn ('k') | tools/mb/mb_config.pyl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698