Skip to content

Commit 4105d74

Browse files
laszlocsomoraehlig
authored andcommitted
Windows,bootstrapping: fix build_windows_jni.sh
Also: - check as the first thing in compile.sh that we can locate the GNU coreutils, and remove the duplicate check for the same thing on Windows - check early in compile.sh that we can access python.exe Fixes #3863 Change-Id: Ib48b405cf93eafd48e21b280bcbab4d45117c1d9 PiperOrigin-RevId: 171291435
1 parent 5cc6246 commit 4105d74

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

compile.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,28 @@
2222

2323
set -o errexit
2424

25-
# Correct PATH on Windows, to avoid using "FIND.EXE" instead of "/usr/bin/find"
26-
# etc, leading to confusing errors.
27-
export BAZEL_OLD_PATH=$PATH
28-
case "$(uname -s | tr [:upper:] [:lower:])" in
29-
msys*|mingw*|cygwin*)
30-
# Check that the PATH is set up correctly by attempting to locate `[`.
31-
# This ensures that `which` is installed correctly and can succeed, while
32-
# also avoids accidentally locating a tool that exists in plain Windows too
33-
# (like "find" for "FIND.EXE").
34-
which [ >&/dev/null || export PATH="/bin:/usr/bin:$PATH"
35-
esac
36-
3725
# Check that the bintools can be found, otherwise we would see very confusing
3826
# error messages.
27+
# For example on Windows we would find "FIND.EXE" instead of "/usr/bin/find"
28+
# when running "find".
3929
hash tr >&/dev/null || {
4030
echo >&2 "ERROR: cannot locate GNU coreutils; check your PATH."
4131
echo >&2 " (You may need to run 'export PATH=/bin:/usr/bin:\$PATH)'"
4232
exit 1
4333
}
4434

35+
# Ensure Python is on the PATH on Windows,otherwise we would see
36+
# "LAUNCHER ERROR" messages from py_binary exe launchers.
37+
case "$(uname -s | tr [:upper:] [:lower:])" in
38+
msys*|mingw*|cygwin*)
39+
which python.exe >&/dev/null || {
40+
echo >&2 "ERROR: cannot locate python.exe; check your PATH."
41+
echo >&2 " (You may need to run 'export PATH=/c/Python27:\$PATH)' or similar,"
42+
echo >&2 " depending on where you installed Python)."
43+
exit 1
44+
}
45+
esac
46+
4547
cd "$(dirname "$0")"
4648

4749
# Set the default verbose mode in buildenv.sh so that we do not display command

scripts/bootstrap/buildenv.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ function atexit() {
129129
ATEXIT_HANDLERS="${ATEXIT_HANDLERS} ${handler}"
130130
}
131131

132-
function restore_saved_path() {
133-
export PATH=$BAZEL_OLD_PATH
134-
export BAZEL_OLD_PATH=
135-
}
136-
137132
# Exit routine to run all registered atexit handlers.
138133
#
139134
# If the program exited with an error, this exit routine will also exit with the
@@ -183,7 +178,6 @@ function cleanup_phasefile() {
183178
}
184179

185180
atexit cleanup_phasefile
186-
atexit restore_saved_path
187181

188182
# Excutes a command respecting the current verbosity settings.
189183
#

src/main/native/windows/build_windows_jni.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ cat > "${VSTEMP}/windows_jni.bat" <<EOF
9999
@call "${VSVARS}" amd64
100100
@cd $(cygpath -a -w "${PWD}")
101101
@set TMP=$(cygpath -a -w "${VSTEMP}")
102-
@CL /O2 /EHsc /LD /Fe:"$(cygpath -a -w ${DLL})" /I "${VSTEMP}" /I . ${WINDOWS_SOURCES[*]}
102+
@CL /O2 /EHsc /LD /Fe:"$(cygpath -a -w ${DLL})" /I "%TMP%" /I . ${WINDOWS_SOURCES[*]}
103103
EOF
104104

105105
# Invoke the file and hopefully generate the .DLL .

0 commit comments

Comments
 (0)