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

Unified Diff: tools/mb/mb.py

Issue 1169923008: Add support for GN's --runtime-deps-list-file flag to MB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to HEAD, add nacl_helper_nonsfi_unittests to fix presubmit failure Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« testing/buildbot/ninja_to_gn.pyl ('K') | « testing/buildbot/ninja_to_gn.pyl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/mb/mb.py
diff --git a/tools/mb/mb.py b/tools/mb/mb.py
index 0c3d446913a6a6d972ebbd675afb70f81395248b..5b99141418a2ef014238cc3b6a0ea506622f9b41 100755
--- a/tools/mb/mb.py
+++ b/tools/mb/mb.py
@@ -89,6 +89,9 @@ class MetaBuildWrapper(object):
subp = subps.add_parser('gen',
help='generate a new set of build files')
AddCommonOptions(subp)
+ subp.add_argument('--swarming-targets-file',
+ help='save runtime dependencies for targets listed '
+ 'in file.')
subp.add_argument('path', nargs=1,
help='path to generate build into')
subp.set_defaults(func=self.CmdGen)
@@ -336,7 +339,35 @@ class MetaBuildWrapper(object):
def RunGNGen(self, path, vals):
cmd = self.GNCmd('gen', path, vals['gn_args'])
+
+ swarming_targets = []
+ if self.args.swarming_targets_file:
+ # We need GN to generate the list of runtime dependencies for
+ # the compile targets listed (one per line) in the file so
+ # we can run them via swarming. We use ninja_to_gn.pyl to convert
+ # the compile targets to the matching GN labels.
+ contents = self.ReadFile(self.args.swarming_targets_file)
+ swarming_targets = contents.splitlines()
+ ninja_targets_to_labels = ast.literal_eval(self.ReadFile(os.path.join(
+ self.chromium_src_dir, 'testing', 'buildbot', 'ninja_to_gn.pyl')))
+ gn_labels = []
+ for target in swarming_targets:
+ if not target in ninja_targets_to_labels:
+ raise MBErr('test target "%s" not found in %s' %
+ (target, '//testing/buildbot/ninja_to_gn.pyl'))
+ gn_labels.append(ninja_targets_to_labels[target])
+
+ gn_runtime_deps_path = self.ToAbsPath(path, 'runtime_deps')
+ self.WriteFile(gn_runtime_deps_path, '\n'.join(gn_labels) + '\n')
+ cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path)
+
ret, _, _ = self.Run(cmd)
+
+ for target in swarming_targets:
+ deps_path = self.ToAbsPath(path, target + '.runtime_deps')
+ if not self.Exists(deps_path):
+ raise MBErr('did not generate %s' % deps_path)
+
return ret
def GNCmd(self, subcommand, path, gn_args=''):
@@ -387,7 +418,7 @@ class MetaBuildWrapper(object):
outp = json.loads(self.ReadFile(self.args.output_path[0]))
self.Print()
self.Print('analyze output:')
- self.PrintJSON(inp)
+ self.PrintJSON(outp)
self.Print()
return ret
@@ -504,10 +535,10 @@ class MetaBuildWrapper(object):
return cmdline, extra_files
- def ToAbsPath(self, build_path, relpath):
+ def ToAbsPath(self, build_path, *comps):
return os.path.join(self.chromium_src_dir,
self.ToSrcRelPath(build_path),
- relpath)
+ *comps)
def ToSrcRelPath(self, path):
"""Returns a relative path from the top of the repo."""
« testing/buildbot/ninja_to_gn.pyl ('K') | « testing/buildbot/ninja_to_gn.pyl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698