From 3f53edbe5e211d3539c31c0b3b82a89bf712c635 Mon Sep 17 00:00:00 2001 From: Debrian Figueroa Date: Fri, 19 Jul 2019 15:15:01 -0700 Subject: [PATCH] Add json output arg to mb gen and analyze. Allows writing of output error to json output path specified. Bug: chromium:985959 Change-Id: I93205451d3537072607b2a243e9a5216ae231099 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146273 Commit-Queue: Debrian Figueroa Reviewed-by: Oleh Prypin Reviewed-by: Dirk Pranke Cr-Commit-Position: refs/heads/master@{#28639} --- tools_webrtc/mb/mb.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools_webrtc/mb/mb.py b/tools_webrtc/mb/mb.py index 924dcc0216..f3e644128a 100755 --- a/tools_webrtc/mb/mb.py +++ b/tools_webrtc/mb/mb.py @@ -121,6 +121,8 @@ class MetaBuildWrapper(object): subp.add_argument('output_path', nargs=1, help='path to a file containing the output arguments ' 'as a JSON object.') + subp.add_argument('--json-output', + help='Write errors to json.output') subp.set_defaults(func=self.CmdAnalyze) subp = subps.add_parser('export', @@ -139,6 +141,8 @@ class MetaBuildWrapper(object): subp.add_argument('--swarming-targets-file', help='save runtime dependencies for targets listed ' 'in file.') + subp.add_argument('--json-output', + help='Write errors to json.output') subp.add_argument('path', nargs=1, help='path to generate build into') subp.set_defaults(func=self.CmdGen) @@ -613,8 +617,11 @@ class MetaBuildWrapper(object): self.WriteFile(gn_runtime_deps_path, '\n'.join(labels) + '\n') cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path) - ret, _, _ = self.Run(cmd) + ret, output, _ = self.Run(cmd) if ret: + if self.args.json_output: + # write errors to json.output + self.WriteJSON({'output': output}, self.args.json_output) # If `gn gen` failed, we should exit early rather than trying to # generate isolates. Run() will have already logged any error output. self.Print('GN gen failed: %d' % ret) @@ -966,8 +973,11 @@ class MetaBuildWrapper(object): try: self.WriteJSON(gn_inp, gn_input_path) cmd = self.GNCmd('analyze', build_path, gn_input_path, gn_output_path) - ret, _, _ = self.Run(cmd, force_verbose=True) + ret, output, _ = self.Run(cmd, force_verbose=True) if ret: + if self.args.json_output: + # write errors to json.output + self.WriteJSON({'output': output}, self.args.json_output) return ret gn_outp_str = self.ReadFile(gn_output_path)