mb: Implement 'quiet' flag in mb lookup
This is a partial port of https://chromium-review.googlesource.com/1576022
Needed because recipes assume the flag exists.
Example error (unnoticed until now because it's silently ignored):
https://logs.chromium.org/logs/webrtc/buildbucket/cr-buildbucket.appspot.com/8911948550157608800/+/steps/lookup_GN_args/0/stdout
Bug: chromium:955062
Change-Id: Id3707903dd5747c13bba05df76f799fb523a6faa
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139248
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28123}
diff --git a/tools_webrtc/mb/mb.py b/tools_webrtc/mb/mb.py
index 8b726bf..43b9cb4 100755
--- a/tools_webrtc/mb/mb.py
+++ b/tools_webrtc/mb/mb.py
@@ -157,6 +157,9 @@
help='look up the command for a given config or '
'builder')
AddCommonOptions(subp)
+ subp.add_argument('--quiet', default=False, action='store_true',
+ help='Print out just the arguments, '
+ 'do not emulate the output of the gen subcommand.')
subp.set_defaults(func=self.CmdLookup)
subp = subps.add_parser(
@@ -286,12 +289,15 @@
def CmdLookup(self):
vals = self.Lookup()
- cmd = self.GNCmd('gen', '_path_')
gn_args = self.GNArgs(vals)
- self.Print('\nWriting """\\\n%s""" to _path_/args.gn.\n' % gn_args)
- env = None
+ if self.args.quiet:
+ self.Print(gn_args, end='')
+ else:
+ cmd = self.GNCmd('gen', '_path_')
+ self.Print('\nWriting """\\\n%s""" to _path_/args.gn.\n' % gn_args)
+ env = None
- self.PrintCmd(cmd, env)
+ self.PrintCmd(cmd, env)
return 0
def CmdRun(self):
diff --git a/tools_webrtc/mb/mb_unittest.py b/tools_webrtc/mb/mb_unittest.py
index 0e7173a..c178000 100755
--- a/tools_webrtc/mb/mb_unittest.py
+++ b/tools_webrtc/mb/mb_unittest.py
@@ -776,6 +776,11 @@
def test_lookup(self):
self.check(['lookup', '-c', 'debug_goma'], ret=0)
+ def test_quiet_lookup(self):
+ self.check(['lookup', '-c', 'debug_goma', '--quiet'], ret=0,
+ out=('is_debug = true\n'
+ 'use_goma = true\n'))
+
def test_lookup_goma_dir_expansion(self):
self.check(['lookup', '-c', 'rel_bot', '-g', '/foo'], ret=0,
out=('\n'