diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-10-17 10:38:35 +0200 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2017-10-18 10:28:05 +0200 |
commit | 68de436955c1f2f906c30199a84d7d1858b52bdf (patch) | |
tree | 9b6c4fd3e8dd758c093a70a859fd5b3f61cc30ef /src/main/native | |
parent | 5de01e5ed348a0b9d9eea88502fcca4b8c4133ed (diff) |
build_windows_jni: fix @cd call
In cmd.exe it's not enough to `cd` into a
directory to change the shell's current working
directory: you also have to change to the right
drive.
Fixes https://github.com/bazelbuild/bazel/issues/3906
Change-Id: I4dd1a17e8b6b4a0db8fb7a56239ed78de3efae95
PiperOrigin-RevId: 172437822
Diffstat (limited to 'src/main/native')
-rw-r--r-- | src/main/native/windows/build_windows_jni.sh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/native/windows/build_windows_jni.sh b/src/main/native/windows/build_windows_jni.sh index ad52518ea2..60b8b2ff2d 100644 --- a/src/main/native/windows/build_windows_jni.sh +++ b/src/main/native/windows/build_windows_jni.sh @@ -94,10 +94,16 @@ cp -f "$JAVAINCLUDES/win32/jni_md.h" "$JNI_HEADERS_DIR/" # CL.EXE needs a bunch of environment variables whose official location is a # batch file. We can't make that have an effect on a bash instance, so # generate a batch file that invokes it. +# As for `abs_pwd` and `pwd_drive`: in cmd.exe, it's not enough to `cd` into a +# directory. You must also change to its drive to truly set the cwd to that +# directory. See https://github.com/bazelbuild/bazel/issues/3906 +abs_pwd="$(cygpath -a -w "${PWD}")" +pwd_drive="$(echo "$abs_pwd" | head -c2)" cat > "${VSTEMP}/windows_jni.bat" <<EOF @echo OFF @call "${VSVARS}" amd64 -@cd $(cygpath -a -w "${PWD}") +@$pwd_drive +@cd "$abs_pwd" @set TMP=$(cygpath -a -w "${VSTEMP}") @CL /O2 /EHsc /LD /Fe:"$(cygpath -a -w ${DLL})" /I "%TMP%" /I . ${WINDOWS_SOURCES[*]} EOF |