Skip to content

Commit

Permalink
Windows,bootstrapping: fix build_windows_jni.sh
Browse files Browse the repository at this point in the history
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
  • Loading branch information
laszlocsomor authored and aehlig committed Oct 6, 2017
1 parent ddc8e0c commit e79a110
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
26 changes: 14 additions & 12 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,28 @@

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*|cygwin*)
# 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.
# For example on Windows we would find "FIND.EXE" instead of "/usr/bin/find"
# when running "find".
hash tr >&/dev/null || {
echo >&2 "ERROR: cannot locate GNU coreutils; check your PATH."
echo >&2 " (You may need to run 'export PATH=/bin:/usr/bin:\$PATH)'"
exit 1
}

# 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
msys*|mingw*|cygwin*)
which python.exe >&/dev/null || {
echo >&2 "ERROR: cannot locate python.exe; check your PATH."
echo >&2 " (You may need to run 'export PATH=/c/Python27:\$PATH)' or similar,"
echo >&2 " depending on where you installed Python)."
exit 1
}
esac

cd "$(dirname "$0")"

# Set the default verbose mode in buildenv.sh so that we do not display command
Expand Down
6 changes: 0 additions & 6 deletions scripts/bootstrap/buildenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ function atexit() {
ATEXIT_HANDLERS="${ATEXIT_HANDLERS} ${handler}"
}

function restore_saved_path() {
export PATH=$BAZEL_OLD_PATH
export BAZEL_OLD_PATH=
}

# Exit routine to run all registered atexit handlers.
#
# If the program exited with an error, this exit routine will also exit with the
Expand Down Expand Up @@ -183,7 +178,6 @@ function cleanup_phasefile() {
}

atexit cleanup_phasefile
atexit restore_saved_path

# Excutes a command respecting the current verbosity settings.
#
Expand Down
2 changes: 1 addition & 1 deletion src/main/native/windows/build_windows_jni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ cat > "${VSTEMP}/windows_jni.bat" <<EOF
@call "${VSVARS}" amd64
@cd $(cygpath -a -w "${PWD}")
@set TMP=$(cygpath -a -w "${VSTEMP}")
@CL /O2 /EHsc /LD /Fe:"$(cygpath -a -w ${DLL})" /I "${VSTEMP}" /I . ${WINDOWS_SOURCES[*]}
@CL /O2 /EHsc /LD /Fe:"$(cygpath -a -w ${DLL})" /I "%TMP%" /I . ${WINDOWS_SOURCES[*]}
EOF

# Invoke the file and hopefully generate the .DLL .
Expand Down

0 comments on commit e79a110

Please sign in to comment.