From f5525e8ddb341ddf96feaefb8cba0e95d28f226b Mon Sep 17 00:00:00 2001 From: Laszlo Csomor Date: Mon, 30 Jan 2017 18:11:58 +0000 Subject: Bazel bootstrapping: make it work on Windows again In this change: (1) add a sanity check to verify that GNU bintools are on the PATH (2) correct the PATH on Windows if (1) failed (3) use "/My Documents/Temp" as the default temp directory instead of "%windir%/Temp", because the latter is non-writable Motivated by: https://github.com/bazelbuild/bazel/issues/2431 https://github.com/bazelbuild/bazel/issues/2449 -- PiperOrigin-RevId: 146006796 MOS_MIGRATED_REVID=146006796 --- compile.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'compile.sh') diff --git a/compile.sh b/compile.sh index dfc3d71015..67223e6715 100755 --- a/compile.sh +++ b/compile.sh @@ -22,6 +22,26 @@ set -o errexit +# Correct PATH on Windows, to avoid using "FIND.EXE" instead of "/usr/bin/find" +# etc, leading to confusing errors. +export BAZEL_OLD_PATH=$PATH +case "$(uname -s | tr [:upper:] [:lower:])" in +msys*|mingw*) + # Check that the PATH is set up correctly by attempting to locate `[`. + # This ensures that `which` is installed correctly and can succeed, while + # also avoids accidentally locating a tool that exists in plain Windows too + # (like "find" for "FIND.EXE"). + which [ >&/dev/null || export PATH="/bin:/usr/bin:$PATH" +esac + +# Check that the bintools can be found, otherwise we would see very confusing +# error messages. +which [ >&/dev/null || { + echo >&2 "ERROR: cannot locate GNU bintools; check your PATH." + echo >&2 " (You may need to run 'export PATH=/bin:/usr/bin:\$PATH)'" + exit 1 +} + cd "$(dirname "$0")" # Set the default verbose mode in buildenv.sh so that we do not display command -- cgit v1.2.3