aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/native/build_windows_jni.sh
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-02-01 11:49:46 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-02-01 14:30:16 +0000
commitb26a5ae3ac8cd5a7c94bb3e23c0253375c88acf4 (patch)
tree140d57ef5266334b5d8470f57bc91044e45bbb9a /src/main/native/build_windows_jni.sh
parent62dbdfec3d7f6effc182f2e15f84acf0b6fa2f72 (diff)
Windows JNI: check and fix the PATH
Also introduce a fail() method and clean up the script a little bit. Fixes https://github.com/bazelbuild/bazel/issues/2464 -- PiperOrigin-RevId: 146225020 MOS_MIGRATED_REVID=146225020
Diffstat (limited to 'src/main/native/build_windows_jni.sh')
-rwxr-xr-xsrc/main/native/build_windows_jni.sh27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/main/native/build_windows_jni.sh b/src/main/native/build_windows_jni.sh
index d10218fe78..f997546f48 100755
--- a/src/main/native/build_windows_jni.sh
+++ b/src/main/native/build_windows_jni.sh
@@ -22,6 +22,18 @@
DLL="$1"
shift 1
+function fail() {
+ echo >&2 "ERROR: $@"
+ exit 1
+}
+
+# Ensure the PATH is set up correctly.
+if ! which which >&/dev/null ; then
+ PATH="/bin:/usr/bin:$PATH"
+ which which >&/dev/null \
+ || fail "System PATH is not set up correctly, cannot run GNU bintools"
+fi
+
# Create a temp directory. It will used for the batch file we generate soon and
# as the temp directory for CL.EXE .
VSTEMP=$(mktemp -d)
@@ -30,11 +42,11 @@ trap "rm -fr \"$VSTEMP\"" EXIT
# Find Visual Studio. We don't have any regular environment variables available
# so this is the best we can do.
if [ -z "${BAZEL_VS+set}" ]; then
- VSVERSION="$(ls "C:/Program Files (x86)" | grep -E "Microsoft Visual Studio [0-9]+" | sort --version-sort | tail -n 1)"
- if [[ "$VSVERSION" == "" ]]; then
- echo "Visual Studio not found"
- exit 1
- fi
+ VSVERSION="$(ls "C:/Program Files (x86)" \
+ | grep -E "Microsoft Visual Studio [0-9]+" \
+ | sort --version-sort \
+ | tail -n 1)"
+ [[ -n "$VSVERSION" ]] || fail "Visual Studio not found"
BAZEL_VS="C:/Program Files (x86)/$VSVERSION"
fi
VSVARS="${BAZEL_VS}/VC/VCVARSALL.BAT"
@@ -42,10 +54,7 @@ VSVARS="${BAZEL_VS}/VC/VCVARSALL.BAT"
# Find Java. $(JAVA) in the BUILD file points to external/local_jdk/..., which
# is not very useful for anything not MSYS-based.
JAVA=$(ls "C:/Program Files/java" | grep -E "^jdk" | sort | tail -n 1)
-if [[ "$JAVA" == "" ]]; then
- echo "JDK not found"
- exit 1
-fi
+[[ -n "$JAVA" ]] || fail "JDK not found"
JAVAINCLUDES="C:/Program Files/java/$JAVA/include"
# Convert all compilation units to Windows paths.