Index: tools/mb/mb.py |
diff --git a/tools/mb/mb.py b/tools/mb/mb.py |
index b9b11963c05aaa834c10596f099aac51ec3b0531..2a010552e3b6cc2d3b076a8f7c6713652bcb40b5 100755 |
--- a/tools/mb/mb.py |
+++ b/tools/mb/mb.py |
@@ -120,6 +120,17 @@ class MetaBuildWrapper(object): |
'as a JSON object.') |
subp.set_defaults(func=self.CmdAnalyze) |
+ subp = subps.add_parser('export', |
+ help='print out the expanded configuration for' |
+ 'each builder as a JSON object') |
+ subp.add_argument('-f', '--config-file', metavar='PATH', |
+ default=self.default_config, |
+ help='path to config file ' |
+ '(default is //tools/mb/mb_config.pyl)') |
+ subp.add_argument('-g', '--goma-dir', |
+ help='path to goma directory') |
+ subp.set_defaults(func=self.CmdExport) |
+ |
subp = subps.add_parser('gen', |
help='generate a new set of build files') |
AddCommonOptions(subp) |
@@ -249,6 +260,33 @@ class MetaBuildWrapper(object): |
else: |
return self.RunGYPAnalyze(vals) |
+ def CmdExport(self): |
+ self.ReadConfigFile() |
+ obj = {} |
+ for master, builders in self.masters.items(): |
+ obj[master] = {} |
+ for builder in builders: |
+ config = self.masters[master][builder] |
+ if not config: |
+ continue |
+ |
+ if isinstance(config, list): |
+ args = [self.FlattenConfig(c)['gn_args'] for c in config] |
+ elif config.startswith('//'): |
+ args = config |
+ else: |
+ args = self.FlattenConfig(config)['gn_args'] |
+ if 'error' in args: |
+ continue |
+ |
+ obj[master][builder] = args |
+ |
+ # Dump object and trim trailing whitespace. |
+ s = '\n'.join(l.rstrip() for l in |
+ json.dumps(obj, sort_keys=True, indent=2).splitlines()) |
+ self.Print(s) |
+ return 0 |
+ |
def CmdGen(self): |
vals = self.Lookup() |
self.ClobberIfNeeded(vals) |
@@ -598,7 +636,8 @@ class MetaBuildWrapper(object): |
# Do some basic sanity checking on the config so that we |
# don't have to do this in every caller. |
- assert 'type' in vals, 'No meta-build type specified in the config' |
+ if 'type' not in vals: |
+ vals['type'] = 'gn' |
assert vals['type'] in ('gn', 'gyp'), ( |
'Unknown meta-build type "%s"' % vals['gn_args']) |
@@ -688,7 +727,7 @@ class MetaBuildWrapper(object): |
vals = { |
'args_file': '', |
'cros_passthrough': False, |
- 'gn_args': [], |
+ 'gn_args': '', |
'gyp_defines': '', |
'gyp_crosscompile': False, |
'type': None, |