From 309f0e0d79130ea75998ded4691052cc489e2004 Mon Sep 17 00:00:00 2001 From: Hector Oswaldo Caballero Date: Mon, 8 Jan 2018 21:54:03 -0500 Subject: [PATCH] [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: I4ae6fdb4df757cd5333e70c13cdded588ec8e194 --- tools/eclipse/project.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py index e63e7390ff..448d940a99 100755 --- a/tools/eclipse/project.py +++ b/tools/eclipse/project.py @@ -51,10 +51,22 @@ opts.add_option('--plugins', help='create eclipse projects for plugins', action='store_true') opts.add_option('--name', help='name of the generated project', action='store', default='gerrit', dest='project_name') +opts.add_option('-b', '--batch', action='store_true', + dest='batch', help='Bazel batch option') args, _ = opts.parse_args() +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 gen_bazel_path(): bazel = check_output(['which', 'bazel']).strip() @@ -66,7 +78,7 @@ def _query_classpath(target): deps = [] t = cp_targets[target] 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' @@ -277,7 +289,7 @@ try: makedirs(path.join(ROOT, gwt_working_dir)) try: - check_call(['bazel', 'build', MAIN, GWT, '//java/org/eclipse/jgit:libEdit-src.jar']) + check_call(_build_bazel_cmd('build', MAIN, GWT, '//java/org/eclipse/jgit:libEdit-src.jar')) except CalledProcessError: exit(1) except KeyboardInterrupt: