Chromium Code Reviews| Index: tools/mb/mb.py |
| diff --git a/tools/mb/mb.py b/tools/mb/mb.py |
| index f1a223ea373a4142c5b2479695954150a5e9698b..a245e4b74829f1a8778236e9206ecd3407ee9b66 100755 |
| --- a/tools/mb/mb.py |
| +++ b/tools/mb/mb.py |
| @@ -63,10 +63,7 @@ class MetaBuildWrapper(object): |
| subp.add_argument('-n', '--dryrun', action='store_true', |
| help='Do a dry run (i.e., do nothing, just print ' |
| 'the commands that will run)') |
| - subp.add_argument('-q', '--quiet', action='store_true', |
| - help='Do not print anything on success, ' |
| - 'just return an exit code.') |
| - subp.add_argument('-v', '--verbose', action='count', |
| + subp.add_argument('-v', '--verbose', action='count', default=0, |
| help='verbose logging (may specify multiple times).') |
| parser = argparse.ArgumentParser(prog='mb') |
| @@ -111,9 +108,6 @@ class MetaBuildWrapper(object): |
| default=self.default_config, |
| help='path to config file ' |
| '(default is //tools/mb/mb_config.pyl)') |
| - subp.add_argument('-q', '--quiet', action='store_true', |
| - help='Do not print anything on success, ' |
| - 'just return an exit code.') |
| subp.set_defaults(func=self.CmdValidate) |
| subp = subps.add_parser('help', |
| @@ -232,8 +226,7 @@ class MetaBuildWrapper(object): |
| raise MBErr(('mb config file %s has problems:' % self.args.config_file) + |
| '\n ' + '\n '.join(errs)) |
| - if not self.args.quiet: |
| - self.Print('mb config file %s looks ok.' % self.args.config_file) |
| + self.Print('mb config file %s looks ok.' % self.args.config_file) |
| return 0 |
| def GetConfig(self): |
| @@ -473,53 +466,6 @@ class MetaBuildWrapper(object): |
| return ret |
| - def RunGNIsolate(self, vals): |
| - build_path = self.args.path[0] |
| - inp = self.ReadInputJSON(['targets']) |
| - 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 = self.GetIsolateCommand(target, vals, None) |
| - |
| - 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), |
| - } |
| - }) + '\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 + 'd.gen.json', |
| - ) |
| - |
| - return 0 |
| - |
| def GetIsolateCommand(self, target, vals, gn_isolate_map): |
| # This needs to mirror the settings in //build/config/ui.gni: |
| # use_x11 = is_linux && !use_ozone. |
| @@ -683,7 +629,7 @@ class MetaBuildWrapper(object): |
| try: |
| cmd = self.GNCmd('refs', self.args.path[0]) + [ |
| '@%s' % response_file.name, '--all', '--as=output'] |
| - ret, out, _ = self.Run(cmd) |
| + ret, out, _ = self.Run(cmd, verbosity=1) |
| if ret and not 'The input matches no targets' in out: |
| self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out), |
| output_path) |
| @@ -695,7 +641,7 @@ class MetaBuildWrapper(object): |
| cmd = self.GNCmd('refs', self.args.path[0]) + [ |
| '@%s' % response_file.name, '--all'] |
| - ret, out, _ = self.Run(cmd) |
| + ret, out, _ = self.Run(cmd, verbosity=1) |
| if ret and not 'The input matches no targets' in out: |
| self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out), |
| output_path) |
| @@ -716,15 +662,15 @@ class MetaBuildWrapper(object): |
| # and both would be listed in the input, but we would only need |
| # to specify target X as a build_target (whereas both X and Y are |
| # targets). I'm not sure if that optimization is generally worth it. |
| - self.WriteJSON({'targets': sorted(matching_targets), |
| - 'build_targets': sorted(matching_targets), |
| + self.WriteJSON({'targets': sorted(set(matching_targets)), |
| + 'build_targets': sorted(set(matching_targets)), |
|
Dirk Pranke
2015/09/11 23:27:52
This fixes a minor annoyance where if multiple tar
|
| 'status': 'Found dependency'}, output_path) |
| else: |
| self.WriteJSON({'targets': [], |
| 'build_targets': [], |
| 'status': 'No dependency'}, output_path) |
| - if not ret and self.args.verbose: |
|
Dirk Pranke
2015/09/11 23:27:52
We don't really care about the return value at thi
|
| + if self.args.verbose: |
| outp = json.loads(self.ReadFile(output_path)) |
| self.Print() |
| self.Print('analyze output:') |
| @@ -754,12 +700,13 @@ class MetaBuildWrapper(object): |
| def WriteFailureAndRaise(self, msg, output_path): |
| if output_path: |
| - self.WriteJSON({'error': msg}, output_path) |
| + self.WriteJSON({'error': msg}, output_path, verbosity=0) |
| raise MBErr(msg) |
| - def WriteJSON(self, obj, path): |
| + def WriteJSON(self, obj, path, verbosity=1): |
|
Nico
2015/09/11 23:31:16
add comment explaining what verbosity means (if it
|
| try: |
| - self.WriteFile(path, json.dumps(obj, indent=2, sort_keys=True) + '\n') |
| + self.WriteFile(path, json.dumps(obj, indent=2, sort_keys=True) + '\n', |
| + verbosity=verbosity) |
| except Exception as e: |
| raise MBErr('Error %s writing to the output path "%s"' % |
| (e, path)) |
| @@ -776,14 +723,15 @@ class MetaBuildWrapper(object): |
| # This function largely exists so it can be overridden for testing. |
| print(*args, **kwargs) |
| - def Run(self, cmd, env=None): |
| + def Run(self, cmd, env=None, verbosity=0): |
| # This function largely exists so it can be overridden for testing. |
| - if self.args.dryrun or self.args.verbose: |
| + if self.args.dryrun or self.args.verbose >= verbosity: |
| self.PrintCmd(cmd) |
| if self.args.dryrun: |
| return 0, '', '' |
| + |
| ret, out, err = self.Call(cmd, env=env) |
| - if self.args.verbose: |
| + if self.args.verbose >= verbosity: |
| if out: |
| self.Print(out, end='') |
| if err: |
| @@ -825,9 +773,9 @@ class MetaBuildWrapper(object): |
| # This function largely exists so it can be overriden for testing. |
| return tempfile.NamedTemporaryFile(mode=mode, delete=False) |
| - def WriteFile(self, path, contents): |
| + def WriteFile(self, path, contents, verbosity=1): |
| # This function largely exists so it can be overriden for testing. |
| - if self.args.dryrun or self.args.verbose: |
| + if self.args.dryrun or self.args.verbose >= verbosity: |
| self.Print('\nWriting """\\\n%s""" to %s.\n' % (contents, path)) |
| with open(path, 'w') as fp: |
| return fp.write(contents) |