[project.py] Add bazel --batch option
When communication between the bazel server and client are blocked
by some (still under investigation [1]) security policy, the only
option is to build with the --batch option. Generating the Eclipse
project, though, was failing because there was no way to pass this
option to the script.
[1] https://github.com/bazelbuild/bazel/issues/3602
Change-Id: I1b9412850e10f58874a46bf714e46ee0a8f6cb2e
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py
index 595fa11..8ae67c5 100755
--- a/tools/eclipse/project.py
+++ b/tools/eclipse/project.py
@@ -36,6 +36,8 @@
opts.add_option('-r', '--root', help='Root directory entry')
opts.add_option('-n', '--name', help='Project name')
opts.add_option('-x', '--exclude', action='append', help='Exclude paths')
+opts.add_option('-b', '--batch', action='store_true',
+ dest='batch', help='Bazel batch option')
args, _ = opts.parse_args()
if not args.root:
@@ -47,13 +49,23 @@
while not path.exists(path.join(ROOT, 'WORKSPACE')):
ROOT = path.dirname(ROOT)
+batch_option = '--batch' if args.batch else None
+
+def _build_bazel_cmd(*args):
+ cmd = ['bazel']
+ if batch_option:
+ cmd.append('--batch')
+ for arg in args:
+ cmd.append(arg)
+ return cmd
+
def retrieve_ext_location():
- return check_output(['bazel', 'info', 'output_base']).strip()
+ return check_output(_build_bazel_cmd('info', 'output_base')).strip()
def _query_classpath():
t = '//tools/eclipse:main_classpath_collect'
try:
- check_call(['bazel', 'build', t])
+ check_call(_build_bazel_cmd('build', t))
except CalledProcessError:
exit(1)
name = 'bazel-bin/tools/eclipse/' + t.split(':')[1] + '.runtime_classpath'