From 307541d9a94893f11dc84ef219e9b08e034f88d9 Mon Sep 17 00:00:00 2001
From: John Koleszar <jkoleszar@google.com>
Date: Wed, 22 Aug 2012 10:48:20 -0700
Subject: [PATCH] all_builds.py: add ability to pass extra configure flags

Useful to pass --target etc to this script on Jenkins.

Change-Id: I9b22339a211df543077bcc84bdef4460f3ca5c9c
---
 tools/all_builds.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tools/all_builds.py b/tools/all_builds.py
index b2bab73000..d1f0c80c03 100755
--- a/tools/all_builds.py
+++ b/tools/all_builds.py
@@ -33,15 +33,27 @@ def list_of_experiments():
 def main(argv):
   # Parse arguments
   options = {"--shard": 0, "--shards": 1}
-  o, _ = getopt.getopt(argv[1:], None, LONG_OPTIONS)
+  if "--" in argv:
+    opt_end_index = argv.index("--")
+  else:
+    opt_end_index = len(argv)
+  try:
+    o, _ = getopt.getopt(argv[1:opt_end_index], None, LONG_OPTIONS)
+  except getopt.GetoptError, err:
+    print str(err)
+    print "Usage: %s [--shard=<n> --shards=<n>] -- [configure flag ...]"%argv[0]
+    sys.exit(2)
+
   options.update(o)
+  extra_args = argv[opt_end_index + 1:]
 
   # Shard experiment list
   shard = int(options["--shard"])
   shards = int(options["--shards"])
   experiments = list_of_experiments()
-  configs = [BASE_COMMAND]
-  configs += ["%s --enable-%s" % (BASE_COMMAND, e) for e in experiments]
+  base_command = " ".join([BASE_COMMAND] + extra_args)
+  configs = [base_command]
+  configs += ["%s --enable-%s" % (base_command, e) for e in experiments]
   my_configs = zip(configs, range(len(configs)))
   my_configs = filter(lambda x: x[1] % shards == shard, my_configs)
   my_configs = [e[0] for e in my_configs]
-- 
GitLab