From 4cb8cb806b7ea6351be0948c50675da8f17b09bd Mon Sep 17 00:00:00 2001 From: Laszlo Csomor Date: Tue, 30 Jan 2018 06:59:49 -0800 Subject: Windows,bootstrapping: respect TMPDIR Respect the user-defined TMPDIR, or use TMP or TEMP on Windows. Since MSYS sets TMP and TEMP to "/tmp" which is actually "/tmp" (e.g. "c:\tools\msys64\tmp"), it is shorter than the Windows-default TEMP directory. This buys us a bit of headroom to not hit path length limits while bootstrapping. Fixes https://github.com/bazelbuild/bazel/issues/4536 Change-Id: I2ab04e3c1c96bc306ef54348cc0c0c2f3fda13ee PiperOrigin-RevId: 183826475 --- compile.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'compile.sh') diff --git a/compile.sh b/compile.sh index 23412730ad..31bb9c4f1c 100755 --- a/compile.sh +++ b/compile.sh @@ -35,8 +35,9 @@ hash tr >&/dev/null || { # Ensure Python is on the PATH on Windows,otherwise we would see # "LAUNCHER ERROR" messages from py_binary exe launchers. -case "$(uname -s | tr [:upper:] [:lower:])" in +case "$(uname -s | tr "[:upper:]" "[:lower:]")" in msys*|mingw*|cygwin*) + # Ensure Python is on the PATH, otherwise the bootstrapping fails later. which python.exe >&/dev/null || { echo >&2 "ERROR: cannot locate python.exe; check your PATH." echo >&2 " You may need to run the following command, or something" @@ -44,6 +45,10 @@ msys*|mingw*|cygwin*) echo >&2 " export PATH=\"/c/Python27:\$PATH\"" exit 1 } + # Ensure TMPDIR uses the user-specified TMPDIR or TMP or TEMP. + # This is necessary to avoid overly longs paths during bootstrapping, see for + # example https://github.com/bazelbuild/bazel/issues/4536 + export TMPDIR="${TMPDIR:-${TMP:-${TEMP:-}}}" esac cd "$(dirname "$0")" -- cgit v1.2.3