Set JAVA_HOME for every invocation of compile.sh .
This is necessary since it's now passed in --javabase= even if no bootstrap build is requested.
Fixes #2384.
--
Change-Id: Icc15d9ec174ce9ed82b703c13449d88ec1d936a1
Reviewed-on: https://cr.bazel.build/8408
PiperOrigin-RevId: 145268264
MOS_MIGRATED_REVID=145268264
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh
index 4e4d87e..502f2c1 100755
--- a/scripts/bootstrap/buildenv.sh
+++ b/scripts/bootstrap/buildenv.sh
@@ -58,6 +58,32 @@
MACHINE_IS_64BIT='yes'
fi
+case "${PLATFORM}" in
+linux)
+ # JAVA_HOME must point to a Java installation.
+ JAVA_HOME="${JAVA_HOME:-$(readlink -f $(which javac) | sed 's_/bin/javac__')}"
+ ;;
+
+freebsd)
+ # JAVA_HOME must point to a Java installation.
+ JAVA_HOME="${JAVA_HOME:-/usr/local/openjdk8}"
+ ;;
+
+darwin)
+ if [[ -z "$JAVA_HOME" ]]; then
+ JAVA_HOME="$(/usr/libexec/java_home -v ${JAVA_VERSION}+ 2> /dev/null)" \
+ || fail "Could not find JAVA_HOME, please ensure a JDK (version ${JAVA_VERSION}+) is installed."
+ fi
+ ;;
+
+msys*|mingw*)
+ # Use a simplified platform string.
+ PLATFORM="mingw"
+ PATHSEP=";"
+ # Find the latest available version of the SDK.
+ JAVA_HOME="${JAVA_HOME:-$(ls -d /c/Program\ Files/Java/jdk* | sort | tail -n 1)}"
+esac
+
# Extension for executables.
EXE_EXT=""
case "${PLATFORM}" in
diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh
index 7030a7d..30495ba 100755
--- a/scripts/bootstrap/compile.sh
+++ b/scripts/bootstrap/compile.sh
@@ -59,33 +59,6 @@
MSYS_DLLS=""
PATHSEP=":"
-case "${PLATFORM}" in
-linux)
- # JAVA_HOME must point to a Java installation.
- JAVA_HOME="${JAVA_HOME:-$(readlink -f $(which javac) | sed 's_/bin/javac__')}"
- ;;
-
-freebsd)
- # JAVA_HOME must point to a Java installation.
- JAVA_HOME="${JAVA_HOME:-/usr/local/openjdk8}"
- ;;
-
-darwin)
- if [[ -z "$JAVA_HOME" ]]; then
- JAVA_HOME="$(/usr/libexec/java_home -v ${JAVA_VERSION}+ 2> /dev/null)" \
- || fail "Could not find JAVA_HOME, please ensure a JDK (version ${JAVA_VERSION}+) is installed."
- fi
- ;;
-
-msys*|mingw*)
- # Use a simplified platform string.
- PLATFORM="mingw"
- PATHSEP=";"
- # Find the latest available version of the SDK.
- JAVA_HOME="${JAVA_HOME:-$(ls -d /c/Program\ Files/Java/jdk* | sort | tail -n 1)}"
-esac
-
-
# Check that javac -version returns a upper version than $JAVA_VERSION.
get_java_version
[ ${JAVA_VERSION#*.} -le ${JAVAC_VERSION#*.} ] || \