Chromium Code Reviews| Index: tools/mb/mb.py |
| diff --git a/tools/mb/mb.py b/tools/mb/mb.py |
| index 3ba59438984fbb8a0364102cf1957a3f563e8ec0..ab14fb8d48d25d93c950a02451e9bf7eb5c61ce6 100755 |
| --- a/tools/mb/mb.py |
| +++ b/tools/mb/mb.py |
| @@ -16,6 +16,7 @@ import ast |
| import json |
| import os |
| import pipes |
| +import pprint |
| import shlex |
| import shutil |
| import sys |
| @@ -92,6 +93,19 @@ class MetaBuildWrapper(object): |
| help='path to generate build into') |
| subp.set_defaults(func=self.CmdGen) |
| + subp = subps.add_parser('isolate', |
| + help='build isolates') |
| + AddCommonOptions(subp) |
| + subp.add_argument('path', type=str, nargs=1, |
| + help='path build was generated into.') |
| + subp.add_argument('input_path', nargs=1, |
| + help='path to a file containing the input arguments ' |
| + 'as a JSON object.') |
| + subp.add_argument('output_path', nargs=1, |
| + help='path to a file containing the output arguments ' |
| + 'as a JSON object.') |
| + subp.set_defaults(func=self.CmdIsolate) |
| + |
| subp = subps.add_parser('lookup', |
| help='look up the command for a given config or ' |
| 'builder') |
| @@ -129,6 +143,14 @@ class MetaBuildWrapper(object): |
| raise MBErr('Unknown meta-build type "%s"' % vals['type']) |
| + def CmdIsolate(self): |
| + vals = self.GetConfig() |
| + if vals['type'] == 'gn': |
| + return self.RunGNIsolate(vals) |
| + if vals['type'] == 'gyp': |
| + return 0 # .isolated files are generated during the compile in GYP. |
|
M-A Ruel
2015/06/03 15:47:18
No, the .isolated.gen.json files are generated dur
Dirk Pranke
2015/06/03 17:15:49
Will update.
|
| + raise MBErr('Unknown meta-build type "%s"' % vals['type']) |
| + |
| def CmdLookup(self): |
| vals = self.GetConfig() |
| if vals['type'] == 'gn': |
| @@ -367,6 +389,139 @@ class MetaBuildWrapper(object): |
| return ret |
| + def RunGNIsolate(self, vals): |
| + build_path = self.args.path[0] |
| + inp = self.GetIsolateInput() |
| + if self.args.verbose: |
| + self.Print() |
| + self.Print('isolate input:') |
| + self.PrintJSON(inp) |
| + self.Print() |
| + output_path = self.args.output_path[0] |
| + |
| + for target in inp['targets']: |
| + runtime_deps_path = self.ToAbsPath(build_path, target + '.runtime_deps') |
| + |
| + if not self.Exists(runtime_deps_path): |
| + self.WriteFailureAndRaise('"%s" does not exist' % runtime_deps_path, |
| + output_path) |
| + |
| + command, extra_files, read_only = self.GetIsolateCommand(target, vals) |
| + |
| + runtime_deps = self.ReadFile(runtime_deps_path).splitlines() |
| + |
| + |
| + isolate_path = self.ToAbsPath(build_path, target + '.isolate') |
| + self.WriteFile(isolate_path, |
| + pprint.pformat({ |
| + 'variables': { |
| + 'command': command, |
| + 'files': sorted(runtime_deps + extra_files), |
| + 'read_only': read_only, |
| + } |
| + }) + '\n') |
| + |
| + self.WriteJSON( |
| + { |
| + 'args': [ |
| + '--isolated', |
| + self.ToSrcRelPath('%s/%s.isolated' % (build_path, target)), |
| + '--isolate', |
| + self.ToSrcRelPath('%s/%s.isolate' % (build_path, target)), |
| + ], |
| + 'dir': self.chromium_src_dir, |
| + 'version': 1, |
| + }, |
| + isolate_path + '.gen.json', |
| + ) |
| + |
| + return 0 |
| + |
| + def GetIsolateInput(self): |
|
M-A Ruel
2015/06/03 15:47:19
ReadIsolateInput ?
And it's not really an isolate,
Dirk Pranke
2015/06/03 17:15:50
It was called GetIsolateInput because we're gettin
|
| + path = self.args.input_path[0] |
| + output_path = self.args.output_path[0] |
| + if not self.Exists(path): |
| + self.WriteFailureAndRaise('"%s" does not exist' % path, output_path) |
| + |
| + try: |
| + inp = json.loads(self.ReadFile(path)) |
| + except Exception as e: |
| + self.WriteFailureAndRaise('Failed to read JSON input from "%s": %s' % |
| + (path, e), output_path) |
| + if not 'targets' in inp: |
| + self.WriteFailureAndRaise('input file is missing a "targets" key', |
| + output_path) |
| + |
| + return inp |
| + |
| + def GetIsolateCommand(self, target, vals): |
|
Dirk Pranke
2015/06/03 02:24:54
This whole function is dodgy and needs to be repla
|
| + output_path = self.args.output_path[0] |
| + |
| + extra_files = [] |
| + |
| + # TODO(dpranke): We should probably pull this from |
|
M-A Ruel
2015/06/03 15:47:18
Yes but obviously this only means that it works wh
Dirk Pranke
2015/06/03 17:15:49
Well, it would only work w/ things using the files
|
| + # the test list info in //testing/buildbot/*.json, |
| + # and assert that the test has can_use_on_swarming_builders: True, |
| + # but we hardcode it here for now. |
| + test_type = {}.get(target, 'gtest_test') |
| + read_only = {}.get(target, 1) |
|
M-A Ruel
2015/06/03 15:47:18
The only test that can't run read_only is unit_tes
Dirk Pranke
2015/06/03 17:15:49
Ok, I'll keep that in mind.
|
| + |
| + # This needs to mirror the settings in //build/config/ui.gni: |
| + # use_x11 = is_linux && !use_ozone. |
| + # TODO(dpranke): Figure out how to keep this in sync better. |
| + use_x11 = (sys.platform == 'linux2' and |
| + not 'target_os="android"' in vals['gn_args'] and |
| + not 'use_ozone=true' in vals['gn_args']) |
| + |
| + asan = 'is_asan=true' in vals['gn_args'] |
| + msan = 'is_msan=true' in vals['gn_args'] |
| + tsan = 'is_tsan=true' in vals['gn_args'] |
| + |
| + executable_suffix = '.exe' if sys.platform == 'win32' else '' |
| + |
| + if test_type == 'gtest_test': |
| + extra_files.append('../../testing/test_env.py') |
| + |
| + if use_x11: |
| + extra_files.append('xdisplaycheck') |
| + extra_files.append('../../testing/xvfb.py') |
| + |
| + cmdline = [ |
| + '../../testing/xvfb.py', |
| + '.', |
| + './' + str(target), |
| + '--brave-new-test-launcher', |
| + '--test-launcher-bot-mode', |
| + '--asan=%d' % asan, |
| + '--msan=%d' % msan, |
| + '--tsan=%d' % tsan, |
| + ] |
| + else: |
| + cmdline = [ |
| + '../../testing/test_env.py', |
| + '.', |
| + './' + str(target) + executable_suffix, |
| + '--brave-new-test-launcher', |
| + '--test-launcher-bot-mode', |
| + '--asan=%d' % asan, |
| + '--msan=%d' % msan, |
| + '--tsan=%d' % tsan, |
| + ] |
| + else: |
| + # TODO(dpranke): Handle script_tests and other types of |
| + # swarmed tests. |
| + self.WriteFailureAndRaise('unknown test type "%s" for %s' % |
| + (test_type, target), |
| + output_path) |
| + |
| + |
| + return cmdline, extra_files, read_only |
| + |
| + def ToAbsPath(self, build_path, relpath): |
| + return os.path.join(self.chromium_src_dir, |
| + self.ToSrcRelPath(build_path), |
| + relpath) |
| + |
| def ToSrcRelPath(self, path): |
| """Returns a relative path from the top of the repo.""" |
| # TODO: Support normal paths in addition to source-absolute paths. |