| Index: tools/mb/mb.py
|
| diff --git a/tools/mb/mb.py b/tools/mb/mb.py
|
| index 1733618715f902660811de782e5601698628c86d..cdf1cc3d46b4b44de7a3e8db6090df0df45b9cd9 100755
|
| --- a/tools/mb/mb.py
|
| +++ b/tools/mb/mb.py
|
| @@ -27,6 +27,13 @@ import urllib2
|
|
|
| from collections import OrderedDict
|
|
|
| +CHROMIUM_SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(
|
| + os.path.abspath(__file__))))
|
| +sys.path = [os.path.join(CHROMIUM_SRC_DIR, 'build')] + sys.path
|
| +
|
| +import gn_helpers
|
| +
|
| +
|
| def main(args):
|
| mbw = MetaBuildWrapper()
|
| return mbw.Main(args)
|
| @@ -34,11 +41,9 @@ def main(args):
|
|
|
| class MetaBuildWrapper(object):
|
| def __init__(self):
|
| - p = os.path
|
| - d = os.path.dirname
|
| - self.chromium_src_dir = p.normpath(d(d(d(p.abspath(__file__)))))
|
| - self.default_config = p.join(self.chromium_src_dir, 'tools', 'mb',
|
| - 'mb_config.pyl')
|
| + self.chromium_src_dir = CHROMIUM_SRC_DIR
|
| + self.default_config = os.path.join(self.chromium_src_dir, 'tools', 'mb',
|
| + 'mb_config.pyl')
|
| self.executable = sys.executable
|
| self.platform = sys.platform
|
| self.sep = os.sep
|
| @@ -255,7 +260,9 @@ class MetaBuildWrapper(object):
|
| def CmdLookup(self):
|
| vals = self.Lookup()
|
| if vals['type'] == 'gn':
|
| - cmd = self.GNCmd('gen', '_path_', vals['gn_args'])
|
| + cmd = self.GNCmd('gen', '_path_')
|
| + gn_args = self.GNArgs(vals)
|
| + self.Print('\nWriting """\\\n%s""" to _path_/args.gn.\n' % gn_args)
|
| env = None
|
| else:
|
| cmd, env = self.GYPCmd('_path_', vals)
|
| @@ -690,7 +697,14 @@ class MetaBuildWrapper(object):
|
| def RunGNGen(self, vals):
|
| build_dir = self.args.path[0]
|
|
|
| - cmd = self.GNCmd('gen', build_dir, vals['gn_args'], extra_args=['--check'])
|
| + cmd = self.GNCmd('gen', build_dir, '--check')
|
| + gn_args = self.GNArgs(vals)
|
| +
|
| + # Since GN hasn't run yet, the build directory may not even exist.
|
| + self.MaybeMakeDirectory(self.ToAbsPath(build_dir))
|
| +
|
| + gn_args_path = self.ToAbsPath(build_dir, 'args.gn')
|
| + self.WriteFile(gn_args_path, gn_args)
|
|
|
| swarming_targets = []
|
| if getattr(self.args, 'swarming_targets_file', None):
|
| @@ -722,10 +736,6 @@ class MetaBuildWrapper(object):
|
| ('//testing/buildbot/gn_isolate_map.pyl', err))
|
|
|
| gn_runtime_deps_path = self.ToAbsPath(build_dir, 'runtime_deps')
|
| -
|
| - # Since GN hasn't run yet, the build directory may not even exist.
|
| - self.MaybeMakeDirectory(self.ToAbsPath(build_dir))
|
| -
|
| self.WriteFile(gn_runtime_deps_path, '\n'.join(gn_labels) + '\n')
|
| cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path)
|
|
|
| @@ -792,7 +802,7 @@ class MetaBuildWrapper(object):
|
| command, extra_files = self.GetIsolateCommand(target, vals, gn_isolate_map)
|
|
|
| label = gn_isolate_map[target_name]['label']
|
| - cmd = self.GNCmd('desc', build_dir, extra_args=[label, 'runtime_deps'])
|
| + cmd = self.GNCmd('desc', build_dir, label, 'runtime_deps')
|
| ret, out, _ = self.Call(cmd)
|
| if ret:
|
| if out:
|
| @@ -841,23 +851,29 @@ class MetaBuildWrapper(object):
|
| isolate_path + 'd.gen.json',
|
| )
|
|
|
| - def GNCmd(self, subcommand, path, gn_args='', extra_args=None):
|
| + def GNCmd(self, subcommand, path, *args):
|
| if self.platform == 'linux2':
|
| subdir, exe = 'linux64', 'gn'
|
| elif self.platform == 'darwin':
|
| subdir, exe = 'mac', 'gn'
|
| else:
|
| subdir, exe = 'win', 'gn.exe'
|
| +
|
| gn_path = self.PathJoin(self.chromium_src_dir, 'buildtools', subdir, exe)
|
|
|
| - cmd = [gn_path, subcommand, path]
|
| + return [gn_path, subcommand, path] + list(args)
|
| +
|
| + def GNArgs(self, vals):
|
| + gn_args = vals['gn_args']
|
| if self.args.goma_dir:
|
| gn_args += ' goma_dir="%s"' % self.args.goma_dir
|
| - if gn_args:
|
| - cmd.append('--args=%s' % gn_args)
|
| - if extra_args:
|
| - cmd.extend(extra_args)
|
| - return cmd
|
| +
|
| + # Canonicalize the arg string into a sorted, newline-separated list
|
| + # of key-value pairs, and de-dup the keys if need be so that only
|
| + # the last instance of each arg is listed.
|
| + gn_args = gn_helpers.ToGNString(gn_helpers.FromGNArgs(gn_args))
|
| +
|
| + return gn_args
|
|
|
| def RunGYPGen(self, vals):
|
| path = self.args.path[0]
|
| @@ -1086,8 +1102,11 @@ class MetaBuildWrapper(object):
|
|
|
| matching_targets = set()
|
| try:
|
| - cmd = self.GNCmd('refs', self.args.path[0]) + [
|
| - '@%s' % response_file.name, '--all', '--as=output']
|
| + cmd = self.GNCmd('refs',
|
| + self.args.path[0],
|
| + '@%s' % response_file.name,
|
| + '--all',
|
| + '--as=output')
|
| ret, out, _ = self.Run(cmd, force_verbose=False)
|
| if ret and not 'The input matches no targets' in out:
|
| self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out),
|
| @@ -1098,8 +1117,10 @@ class MetaBuildWrapper(object):
|
| if build_output in targets:
|
| matching_targets.add(build_output)
|
|
|
| - cmd = self.GNCmd('refs', self.args.path[0]) + [
|
| - '@%s' % response_file.name, '--all']
|
| + cmd = self.GNCmd('refs',
|
| + self.args.path[0],
|
| + '@%s' % response_file.name,
|
| + '--all')
|
| ret, out, _ = self.Run(cmd, force_verbose=False)
|
| if ret and not 'The input matches no targets' in out:
|
| self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out),
|
|
|