blob: f489960ea05eb02d9a4162f25d05554ed4daf976 [file] [log] [blame]
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +00001#!/bin/bash
2
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00003# Copyright 2015 The Bazel Authors. All rights reserved.
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +00004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Script for building bazel from scratch without bazel
18
Klaus Aehligf0099012016-09-28 12:13:17 +000019PROTO_FILES=$(ls src/main/protobuf/*.proto src/main/java/com/google/devtools/build/lib/buildeventstream/proto/*.proto)
Klaus Aehlig76eb2a42018-01-19 02:44:58 -080020LIBRARY_JARS=$(find third_party -name '*.jar' | grep -Fv JavaBuilder | grep -Fv third_party/guava | grep -Fv third_party/guava | grep -ve 'third_party/grpc/grpc.*jar' | tr "\n" " ")
Carl Mastrangelo38ff3962018-03-07 08:52:04 -080021GRPC_JAVA_VERSION=1.10.0
Androbinef381e52017-12-14 07:24:27 -080022GRPC_LIBRARY_JARS=$(find third_party/grpc -name '*.jar' | grep -e ".*${GRPC_JAVA_VERSION}.*jar" | tr "\n" " ")
philwobed8c5f2018-07-25 04:44:15 -070023GUAVA_VERSION=25.1
Androbinef381e52017-12-14 07:24:27 -080024GUAVA_JARS=$(find third_party/guava -name '*.jar' | grep -e ".*${GUAVA_VERSION}.*jar" | tr "\n" " ")
Damien Martin-Guillerezd72bc572017-03-07 16:40:41 +000025LIBRARY_JARS="${LIBRARY_JARS} ${GRPC_LIBRARY_JARS} ${GUAVA_JARS}"
Nathan Harmata8a475902016-11-23 19:08:12 +000026
27# tl;dr - error_prone_core contains a copy of an older version of guava, so we
28# need to make sure the newer version of guava always appears first on the
29# classpath.
30#
31# Please read the comment in third_party/BUILD for more details.
32LIBRARY_JARS_ARRAY=($LIBRARY_JARS)
Greg Steuckfce20d792018-06-04 23:10:39 -070033for i in $(eval echo {0..$((${#LIBRARY_JARS_ARRAY[@]} - 1))})
Nathan Harmata8a475902016-11-23 19:08:12 +000034do
Damien Martin-Guillerezb46631b2017-01-20 13:27:26 +000035 [[ "${LIBRARY_JARS_ARRAY[$i]}" =~ ^"third_party/error_prone/error_prone_core-".*\.jar$ ]] && ERROR_PRONE_INDEX=$i
36 [[ "${LIBRARY_JARS_ARRAY[$i]}" =~ ^"third_party/guava/guava-".*\.jar$ ]] && GUAVA_INDEX=$i
Nathan Harmata8a475902016-11-23 19:08:12 +000037done
38[ "${ERROR_PRONE_INDEX:+present}" = "present" ] || { echo "no error prone jar"; echo "${LIBRARY_JARS_ARRAY[@]}"; exit 1; }
39[ "${GUAVA_INDEX:+present}" = "present" ] || { echo "no guava jar"; exit 1; }
40if [ "$ERROR_PRONE_INDEX" -lt "$GUAVA_INDEX" ]; then
41 TEMP_FOR_SWAP="${LIBRARY_JARS_ARRAY[$ERROR_PRONE_INDEX]}"
42 LIBRARY_JARS_ARRAY[$ERROR_PRONE_INDEX]="${LIBRARY_JARS_ARRAY[$GUAVA_INDEX]}"
43 LIBRARY_JARS_ARRAY[$GUAVA_INDEX]="$TEMP_FOR_SWAP"
Androbin9c78a792017-11-29 01:31:47 -080044 LIBRARY_JARS="${LIBRARY_JARS_ARRAY[*]}"
Nathan Harmata8a475902016-11-23 19:08:12 +000045fi
46
Damien Martin-Guillereze700e722016-06-30 15:06:39 +020047DIRS=$(echo src/{java_tools/singlejar/java/com/google/devtools/build/zip,main/java,tools/xcode-common/java/com/google/devtools/build/xcode/{common,util}} third_party/java/dd_plist/java ${OUTPUT_DIR}/src)
dmartingf0b82952017-09-19 14:54:30 +020048EXCLUDE_FILES="src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/testing/*"
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000049
Alexander Chungfc071422017-02-07 12:48:26 +000050mkdir -p "${OUTPUT_DIR}/classes"
51mkdir -p "${OUTPUT_DIR}/src"
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000052
53# May be passed in from outside.
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000054ZIPOPTS="$ZIPOPTS"
55
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000056unset JAVA_TOOL_OPTIONS
57unset _JAVA_OPTIONS
58
59LDFLAGS=${LDFLAGS:-""}
60
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000061MSYS_DLLS=""
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000062
Harsh Vardhanfe04cfd2017-03-21 15:27:12 +000063function get_minor_java_version() {
64 get_java_version
hlopko35664742017-05-29 17:03:07 +020065 java_minor_version=$(echo $JAVA_VERSION | sed 's/[^.][^.]*\.//' | sed 's/\..*$//')
66 javac_minor_version=$(echo $JAVAC_VERSION | sed 's/[^.][^.]*\.//' | sed 's/\..*$//')
Harsh Vardhanfe04cfd2017-03-21 15:27:12 +000067}
68
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000069# Check that javac -version returns a upper version than $JAVA_VERSION.
Harsh Vardhanfe04cfd2017-03-21 15:27:12 +000070get_minor_java_version
71[ ${java_minor_version} -le ${javac_minor_version} ] || \
Damien Martin-Guillerez338dc562015-06-23 17:15:12 +000072 fail "JDK version (${JAVAC_VERSION}) is lower than ${JAVA_VERSION}, please set \$JAVA_HOME."
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000073
74JAR="${JAVA_HOME}/bin/jar"
75
76# Compiles java classes.
77function java_compilation() {
78 local name=$1
79 local directories=$2
Lukacs Berkie21e5922016-04-12 12:22:20 +000080 local excludes=$3
81 local library_jars=$4
82 local output=$5
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000083
Laszlo Csomor54029932016-12-19 15:43:31 +000084 local classpath=${library_jars// /$PATHSEP}${PATHSEP}$5
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000085 local sourcepath=${directories// /$PATHSEP}
86
87 tempdir
88 local tmp="${NEW_TMPDIR}"
89 local paramfile="${tmp}/param"
Lukacs Berkie21e5922016-04-12 12:22:20 +000090 local filelist="${tmp}/filelist"
91 local excludefile="${tmp}/excludefile"
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +000092 touch $paramfile
93
94 mkdir -p "${output}/classes"
95
96 # Compile .java files (incl. generated ones) using javac
97 log "Compiling $name code..."
Lukacs Berkie21e5922016-04-12 12:22:20 +000098 find ${directories} -name "*.java" | sort > "$filelist"
99 # Quotes around $excludes intentionally omitted in the for statement so that
100 # it's split on spaces
101 (for i in $excludes; do
102 echo $i
103 done) | sort > "$excludefile"
104
105 comm -23 "$filelist" "$excludefile" > "$paramfile"
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000106
107 if [ ! -z "$BAZEL_DEBUG_JAVA_COMPILATION" ]; then
108 echo "directories=${directories}" >&2
109 echo "classpath=${classpath}" >&2
110 echo "sourcepath=${sourcepath}" >&2
111 echo "libraries=${library_jars}" >&2
112 echo "output=${output}/classes" >&2
113 echo "List of compiled files:" >&2
114 cat "$paramfile" >&2
115 fi
116
Googler09222fa2018-06-14 08:06:32 -0700117 # Use BAZEL_JAVAC_OPTS to pass additional arguments to javac, e.g.,
118 # export BAZEL_JAVAC_OPTS="-J-Xmx2g -J-Xms200m"
119 # Useful if your system chooses too small of a max heap for javac.
120 # We intentionally rely on shell word splitting to allow multiple
121 # additional arguments to be passed to javac.
Julio Merino5909d9d2016-02-25 21:44:31 +0000122 run "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}" \
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000123 -d "${output}/classes" -source "$JAVA_VERSION" -target "$JAVA_VERSION" \
Googler09222fa2018-06-14 08:06:32 -0700124 -encoding UTF-8 ${BAZEL_JAVAC_OPTS} "@${paramfile}"
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000125
126 log "Extracting helper classes for $name..."
127 for f in ${library_jars} ; do
Julio Merino5909d9d2016-02-25 21:44:31 +0000128 run unzip -qn ${f} -d "${output}/classes"
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000129 done
130}
131
132# Create the deploy JAR
133function create_deploy_jar() {
134 local name=$1
135 local mainClass=$2
136 local output=$3
137 shift 3
138 local packages=""
139 for i in $output/classes/*; do
140 local package=$(basename $i)
141 if [[ "$package" != "META-INF" ]]; then
142 packages="$packages -C $output/classes $package"
143 fi
144 done
145
146 log "Creating $name.jar..."
147 echo "Main-Class: $mainClass" > $output/MANIFEST.MF
Julio Merino5909d9d2016-02-25 21:44:31 +0000148 run "$JAR" cmf $output/MANIFEST.MF $output/$name.jar $packages "$@"
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000149}
150
Klaus Aehlig967a0a32016-12-02 15:08:25 +0000151HOW_TO_BOOTSTRAP='
152
153--------------------------------------------------------------------------------
154NOTE: This failure is likely occuring if you are trying to bootstrap bazel from
155a developer checkout. Those checkouts do not include the generated output of
156the protoc compiler (as we prefer not to version generated files).
157
158* To build a developer version of bazel, do
159
160 bazel build //src:bazel
161
162* To bootstrap your first bazel binary, please download a dist archive from our
163 release page at https://github.com/bazelbuild/bazel/releases and run
164 compile.sh on the unpacked archive.
165
166The full install instructions to install a release version of bazel can be found
dzc5596d3b2017-06-07 21:51:52 -0400167at https://docs.bazel.build/install-compile-source.html
Klaus Aehlig967a0a32016-12-02 15:08:25 +0000168For a rationale, why the bootstrap process is organized in this way, see
169https://bazel.build/designs/2016/10/11/distribution-artifact.html
170--------------------------------------------------------------------------------
171
172'
173
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000174if [ -z "${BAZEL_SKIP_JAVA_COMPILATION}" ]; then
Klaus Aehligd700dff52016-11-23 16:53:22 +0000175
176 if [ -d derived/src/java ]
177 then
178 log "Using pre-generated java proto files"
179 mkdir -p "${OUTPUT_DIR}/src"
180 cp -r derived/src/java/* "${OUTPUT_DIR}/src"
181 else
182
183 [ -n "${PROTOC}" ] \
Klaus Aehlig967a0a32016-12-02 15:08:25 +0000184 || fail "Must specify PROTOC if not bootstrapping from the distribution artifact${HOW_TO_BOOTSTRAP}"
Klaus Aehligd700dff52016-11-23 16:53:22 +0000185
186 [ -n "${GRPC_JAVA_PLUGIN}" ] \
Klaus Aehlig967a0a32016-12-02 15:08:25 +0000187 || fail "Must specify GRPC_JAVA_PLUGIN if not bootstrapping from the distribution artifact${HOW_TO_BOOTSTRAP}"
Klaus Aehligd700dff52016-11-23 16:53:22 +0000188
189 [[ -x "${PROTOC-}" ]] \
190 || fail "Protobuf compiler not found in ${PROTOC-}"
191
192 [[ -x "${GRPC_JAVA_PLUGIN-}" ]] \
193 || fail "gRPC Java plugin not found in ${GRPC_JAVA_PLUGIN-}"
194
195 log "Compiling Java stubs for protocol buffers..."
196 for f in $PROTO_FILES ; do
Olivier Chafik98be14f2017-11-29 07:34:49 -0800197 run "${PROTOC}" \
198 -I. \
199 -Isrc/main/protobuf/ \
Klaus Aehligd700dff52016-11-23 16:53:22 +0000200 -Isrc/main/java/com/google/devtools/build/lib/buildeventstream/proto/ \
201 --java_out=${OUTPUT_DIR}/src \
202 --plugin=protoc-gen-grpc="${GRPC_JAVA_PLUGIN-}" \
203 --grpc_out=${OUTPUT_DIR}/src "$f"
204 done
205 fi
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000206
Lukacs Berkie21e5922016-04-12 12:22:20 +0000207 java_compilation "Bazel Java" "$DIRS" "$EXCLUDE_FILES" "$LIBRARY_JARS" "${OUTPUT_DIR}"
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000208
209 # help files: all non java and BUILD files in src/main/java.
210 for i in $(find src/main/java -type f -a \! -name '*.java' -a \! -name 'BUILD' | sed 's|src/main/java/||'); do
211 mkdir -p $(dirname ${OUTPUT_DIR}/classes/$i)
212 cp src/main/java/$i ${OUTPUT_DIR}/classes/$i
213 done
214
John Cater32c5add2018-03-19 08:51:46 -0700215 # Create the bazel_tools repository.
216 BAZEL_TOOLS_REPO=${OUTPUT_DIR}/embedded_tools
217 mkdir -p ${BAZEL_TOOLS_REPO}
218 cat <<EOF >${BAZEL_TOOLS_REPO}/WORKSPACE
219workspace(name = 'bazel_tools')
220EOF
221 link_dir ${PWD}/src ${BAZEL_TOOLS_REPO}/src
222 link_dir ${PWD}/third_party ${BAZEL_TOOLS_REPO}/third_party
223 link_dir ${PWD}/tools ${BAZEL_TOOLS_REPO}/tools
224
225 # Set up @bazel_tools//platforms properly
226 mkdir -p ${BAZEL_TOOLS_REPO}/platforms
227 cp tools/platforms/platforms.BUILD ${BAZEL_TOOLS_REPO}/platforms/BUILD
228
Damien Martin-Guillerez12c68aa2016-01-15 13:18:11 +0000229 # Overwrite tools.WORKSPACE, this is only for the bootstrap binary
Klaus Aehlig286cfdd2016-10-17 16:47:55 +0000230 chmod u+w "${OUTPUT_DIR}/classes/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE"
Damien Martin-Guillerezbe5b2eb2016-03-02 16:08:07 +0000231 cat <<EOF >${OUTPUT_DIR}/classes/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE
John Cater32c5add2018-03-19 08:51:46 -0700232local_repository(name = 'bazel_tools', path = '${BAZEL_TOOLS_REPO}')
Damien Martin-Guillerezbe5b2eb2016-03-02 16:08:07 +0000233bind(name = "cc_toolchain", actual = "@bazel_tools//tools/cpp:default-toolchain")
234EOF
Damien Martin-Guillerez12c68aa2016-01-15 13:18:11 +0000235
michajlo7131b2c2018-04-09 09:25:50 -0700236 create_deploy_jar "libblaze" "com.google.devtools.build.lib.bazel.Bazel" \
Han-Wen Nienhuysa4b61822015-11-09 13:55:44 +0000237 ${OUTPUT_DIR}
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000238fi
239
Damien Martin-Guillerezdaffc352016-01-18 15:20:32 +0000240log "Creating Bazel install base..."
241ARCHIVE_DIR=${OUTPUT_DIR}/archive
242mkdir -p ${ARCHIVE_DIR}/_embedded_binaries
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000243
Damien Martin-Guillerezdceee0e2016-01-18 11:57:26 +0000244# Dummy build-runfiles
Damien Martin-Guillerezdaffc352016-01-18 15:20:32 +0000245cat <<'EOF' >${ARCHIVE_DIR}/_embedded_binaries/build-runfiles${EXE_EXT}
Klaus Aehlig6992e682016-08-05 12:27:21 +0000246#!/bin/sh
Lukacs Berki25f35692016-08-04 10:38:36 +0000247mkdir -p $2
Damien Martin-Guillerezdceee0e2016-01-18 11:57:26 +0000248cp $1 $2/MANIFEST
249EOF
Damien Martin-Guillerezdaffc352016-01-18 15:20:32 +0000250chmod 0755 ${ARCHIVE_DIR}/_embedded_binaries/build-runfiles${EXE_EXT}
Damien Martin-Guillerezd47a8ef2015-06-10 11:54:50 +0000251
Laszlo Csomord40c78a2016-12-20 10:22:17 +0000252function build_jni() {
253 local -r output_dir=$1
254
Laszlo Csomord0d7ef02017-04-26 10:48:00 +0200255 if [ "${PLATFORM}" = "windows" ]; then
Laszlo Csomord40c78a2016-12-20 10:22:17 +0000256 # We need JNI on Windows because some filesystem operations are not (and
257 # cannot be) implemented in native Java.
258 log "Building Windows JNI library..."
259
260 local -r jni_lib_name="windows_jni.dll"
261 local -r output="${output_dir}/${jni_lib_name}"
262 local -r tmp_output="${NEW_TMPDIR}/jni/${jni_lib_name}"
263 mkdir -p "$(dirname "$tmp_output")"
264 mkdir -p "$(dirname "$output")"
265
266 # Keep this `find` command in sync with the `srcs` of
Laszlo Csomor94091092017-07-04 05:45:40 -0400267 # //src/main/native/windows:windows_jni
Laszlo Csomor17770e52017-06-29 17:43:05 +0200268 local srcs=$(find src/main/native/windows -name '*.cc' -o -name '*.h')
Laszlo Csomord40c78a2016-12-20 10:22:17 +0000269 [ -n "$srcs" ] || fail "Could not find sources for Windows JNI library"
270
271 # do not quote $srcs because we need to expand it to multiple args
Laszlo Csomor94091092017-07-04 05:45:40 -0400272 src/main/native/windows/build_windows_jni.sh "$tmp_output" ${srcs}
Laszlo Csomord40c78a2016-12-20 10:22:17 +0000273
274 cp "$tmp_output" "$output"
275 chmod 0555 "$output"
276
277 JNI_FLAGS="-Dio.bazel.EnableJni=1 -Djava.library.path=${output_dir}"
Laszlo Csomord0d7ef02017-04-26 10:48:00 +0200278 else
Laszlo Csomord40c78a2016-12-20 10:22:17 +0000279 # We don't need JNI on other platforms.
280 JNI_FLAGS="-Dio.bazel.EnableJni=0"
Laszlo Csomord0d7ef02017-04-26 10:48:00 +0200281 fi
Laszlo Csomord40c78a2016-12-20 10:22:17 +0000282}
283
Laszlo Csomor03f78f52017-06-14 15:46:05 +0200284# Computes the value of the bazel.windows_unix_root JVM flag.
285# Prints the JVM flag verbatim on Windows, ready to be passed to the JVM.
286# Prints an empty string on other platforms.
287function windows_unix_root_jvm_flag() {
288 if [ "${PLATFORM}" != "windows" ]; then
289 echo ""
290 return
291 fi
292 [ -n "${BAZEL_SH}" ] || fail "\$BAZEL_SH is not defined"
293 if [ "$(basename "$BAZEL_SH")" = "bash.exe" ]; then
294 local result="$(dirname "$BAZEL_SH")"
295 if [ "$(basename "$result")" = "bin" ]; then
296 result="$(dirname "$result")"
297 if [ "$(basename "$result")" = "usr" ]; then
298 result="$(dirname "$result")"
299 fi
300 # Print the JVM flag. Replace backslashes with forward slashes so the JVM
301 # and the shell won't believe that backslashes are escaping characters.
302 echo "-Dbazel.windows_unix_root=${result//\\//}"
303 return
304 fi
305 fi
306 fail "\$BAZEL_SH=${BAZEL_SH}, must end with \"bin\\bash.exe\" or \"usr\\bin\\bash.exe\""
307}
308
Laszlo Csomord40c78a2016-12-20 10:22:17 +0000309build_jni "${ARCHIVE_DIR}/_embedded_binaries"
310
Damien Martin-Guillerezdaffc352016-01-18 15:20:32 +0000311cp src/main/tools/jdk.BUILD ${ARCHIVE_DIR}/_embedded_binaries/jdk.BUILD
312cp $OUTPUT_DIR/libblaze.jar ${ARCHIVE_DIR}
Chris Parsons381850e2016-08-31 17:04:17 +0000313
314# TODO(b/28965185): Remove when xcode-locator is no longer required in embedded_binaries.
315log "Compiling xcode-locator..."
316if [[ $PLATFORM == "darwin" ]]; then
317 run /usr/bin/xcrun clang -fobjc-arc -framework CoreServices -framework Foundation -o ${ARCHIVE_DIR}/_embedded_binaries/xcode-locator tools/osx/xcode_locator.m
318else
319 cp tools/osx/xcode_locator_stub.sh ${ARCHIVE_DIR}/_embedded_binaries/xcode-locator
320fi
Chris Parsonsf4888182016-01-08 00:42:14 +0000321
Laszlo Csomord0d7ef02017-04-26 10:48:00 +0200322function get_cwd() {
323 local result=${PWD}
324 [ "$PLATFORM" = "windows" ] && result="$(cygpath -m "$result")"
325 echo "$result"
326}
327
Laszlo Csomor9f7180f2016-09-27 13:07:43 +0000328function run_bazel_jar() {
329 local command=$1
330 shift
Yun Peng8efd2822017-03-09 13:15:41 +0000331 local client_env=()
Damien Martin-Guillerez755669f2017-05-08 12:27:38 -0400332 # Propagate all environment variables to bootstrapped Bazel.
hlopko200479a2017-05-09 07:10:35 -0400333 # See https://stackoverflow.com/questions/41898503/loop-over-environment-variables-in-posix-sh
Laszlo Csomor0a936d12017-05-31 09:47:43 +0200334 local env_vars="$(awk 'END { for (name in ENVIRON) { if(name != "_" && name ~ /^[A-Za-z0-9_]*$/) print name; } }' </dev/null)"
Nicolas Lopezbcbdb872017-03-28 08:08:50 +0000335 for varname in $env_vars; do
Dmitry Lomov31fab292017-03-07 18:33:08 +0000336 eval value=\$$varname
Laszlo Csomor0a936d12017-05-31 09:47:43 +0200337 if [ "${PLATFORM}" = "windows" ] && echo "$varname" | grep -q -i "^\(path\|tmp\|temp\|tempdir\|systemroot\)$" ; then
338 varname="$(echo "$varname" | tr [:lower:] [:upper:])"
339 fi
Yun Peng8efd2822017-03-09 13:15:41 +0000340 if [ "${value}" ]; then
341 client_env=("${client_env[@]}" --client_env="${varname}=${value}")
Dmitry Lomov31fab292017-03-07 18:33:08 +0000342 fi
343 done
344
Dmitry Lomovf9f2e102016-01-29 14:26:46 +0000345 "${JAVA_HOME}/bin/java" \
Philipp Wollermann74cb8c72016-07-15 14:01:37 +0000346 -XX:+HeapDumpOnOutOfMemoryError -Xverify:none -Dfile.encoding=ISO-8859-1 \
Carmi Grushko4068a1d2016-06-22 18:43:13 +0000347 -XX:HeapDumpPath=${OUTPUT_DIR} \
Laszlo Csomor03f78f52017-06-14 15:46:05 +0200348 $(windows_unix_root_jvm_flag) \
Damien Martin-Guillerezdaffc352016-01-18 15:20:32 +0000349 -Djava.util.logging.config.file=${OUTPUT_DIR}/javalog.properties \
Laszlo Csomord40c78a2016-12-20 10:22:17 +0000350 ${JNI_FLAGS} \
Damien Martin-Guillerezdaffc352016-01-18 15:20:32 +0000351 -jar ${ARCHIVE_DIR}/libblaze.jar \
352 --batch \
353 --install_base=${ARCHIVE_DIR} \
354 --output_base=${OUTPUT_DIR}/out \
Klaus Aehligc2499c42018-02-27 05:47:21 -0800355 --output_user_root=${OUTPUT_DIR}/user_root \
Damien Martin-Guillerezdaffc352016-01-18 15:20:32 +0000356 --install_md5= \
cushon849df362018-05-14 01:51:45 -0700357 --default_system_javabase="${JAVA_HOME}" \
Laszlo Csomord0d7ef02017-04-26 10:48:00 +0200358 --workspace_directory="$(get_cwd)" \
Kristina Chodorow4873e562016-06-20 14:17:50 +0000359 --nofatal_event_bus_exceptions \
Klaus Aehlig276a8cd2016-07-11 12:06:07 +0000360 ${BAZEL_DIR_STARTUP_OPTIONS} \
Laszlo Csomor50f6bba2016-09-26 14:10:25 +0000361 ${BAZEL_BOOTSTRAP_STARTUP_OPTIONS:-} \
Laszlo Csomor9f7180f2016-09-27 13:07:43 +0000362 $command \
Damien Martin-Guillerez51a204a2016-02-08 14:59:59 +0000363 --ignore_unsupported_sandboxing \
Damien Martin-Guillerezdaffc352016-01-18 15:20:32 +0000364 --startup_time=329 --extract_data_time=523 \
Klaus Aehlig7038d3f2016-03-16 15:41:22 +0000365 --rc_source=/dev/null --isatty=1 \
Philipp Wollermann4c558982017-07-27 18:01:12 +0200366 --build_python_zip \
Yun Peng8efd2822017-03-09 13:15:41 +0000367 "${client_env[@]}" \
Laszlo Csomord0d7ef02017-04-26 10:48:00 +0200368 --client_cwd="$(get_cwd)" \
Damien Martin-Guillerezdaffc352016-01-18 15:20:32 +0000369 "${@}"
370}