Windows, bootstrapping: fix bugs to support Cygwin
We can't yet fully bootstrap Bazel on Cygwin, but
can build Bazel from scratch. Building Bazel with
Bazel fails because gcc isn't found where it's
believed to be -- /usr/bin is a mount in Cygwin
(to /bin), not a symlink or directory.
In this change I:
- added support for the Cygwin shell as a
bootstrap platform (recognize `uname`)
- updateed the bootstrap scripts to use "windows"
as the PLATFORM string, not "mingw"
- fixed the git lookup code
- removed some hardwired msys-style path
- added a cygpath call to convert $PWD to a
mixed-style (otherwise the bootstrap script
passes --client_cwd=/cygdrive/c/... to the
server and WindowsFileSystem.java wants to make
that relative to c:/cygwin64)
See https://github.com/bazelbuild/bazel/issues/2885
Change-Id: Icc71261ea4f0c6d4a9c0846551a7977ca6020331
PiperOrigin-RevId: 154273014
diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh
index 08687ac..eec6123 100755
--- a/scripts/bootstrap/compile.sh
+++ b/scripts/bootstrap/compile.sh
@@ -272,8 +272,7 @@
function build_jni() {
local -r output_dir=$1
- case "${PLATFORM}" in
- msys*|mingw*)
+ if [ "${PLATFORM}" = "windows" ]; then
# We need JNI on Windows because some filesystem operations are not (and
# cannot be) implemented in native Java.
log "Building Windows JNI library..."
@@ -297,13 +296,10 @@
chmod 0555 "$output"
JNI_FLAGS="-Dio.bazel.EnableJni=1 -Djava.library.path=${output_dir}"
- ;;
-
- *)
+ else
# We don't need JNI on other platforms.
JNI_FLAGS="-Dio.bazel.EnableJni=0"
- ;;
- esac
+ fi
}
build_jni "${ARCHIVE_DIR}/_embedded_binaries"
@@ -319,6 +315,12 @@
cp tools/osx/xcode_locator_stub.sh ${ARCHIVE_DIR}/_embedded_binaries/xcode-locator
fi
+function get_cwd() {
+ local result=${PWD}
+ [ "$PLATFORM" = "windows" ] && result="$(cygpath -m "$result")"
+ echo "$result"
+}
+
function run_bazel_jar() {
local command=$1
shift
@@ -369,7 +371,7 @@
--install_base=${ARCHIVE_DIR} \
--output_base=${OUTPUT_DIR}/out \
--install_md5= \
- --workspace_directory=${PWD} \
+ --workspace_directory="$(get_cwd)" \
--nofatal_event_bus_exceptions \
${BAZEL_DIR_STARTUP_OPTIONS} \
${BAZEL_BOOTSTRAP_STARTUP_OPTIONS:-} \
@@ -378,6 +380,6 @@
--startup_time=329 --extract_data_time=523 \
--rc_source=/dev/null --isatty=1 \
"${client_env[@]}" \
- --client_cwd=${PWD} \
+ --client_cwd="$(get_cwd)" \
"${@}"
}