diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-04-26 10:48:00 +0200 |
---|---|---|
committer | Vladimir Moskva <vladmos@google.com> | 2017-04-26 12:44:32 +0200 |
commit | d0d7ef0830ccd0c43a10956abaa8331b06d80e63 (patch) | |
tree | 31cbb7a48fb832a7b5bee0b96aabc953096a723a /scripts/bootstrap | |
parent | bcd23553f38f54fd4846aa507c827a4ee40cfab4 (diff) |
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
Diffstat (limited to 'scripts/bootstrap')
-rwxr-xr-x | scripts/bootstrap/bootstrap.sh | 3 | ||||
-rwxr-xr-x | scripts/bootstrap/buildenv.sh | 14 | ||||
-rwxr-xr-x | scripts/bootstrap/compile.sh | 20 |
3 files changed, 20 insertions, 17 deletions
diff --git a/scripts/bootstrap/bootstrap.sh b/scripts/bootstrap/bootstrap.sh index 3832692d38..c50afc249a 100755 --- a/scripts/bootstrap/bootstrap.sh +++ b/scripts/bootstrap/bootstrap.sh @@ -62,7 +62,8 @@ if [ -z "${BAZEL-}" ]; then --javacopt="-g -source ${JAVA_VERSION} -target ${JAVA_VERSION}" "${@}" } else - function _run_bootstrapping_bazel() { local command=$1 + function _run_bootstrapping_bazel() { + local command=$1 shift ${BAZEL} --bazelrc=${BAZELRC} ${BAZEL_DIR_STARTUP_OPTIONS} $command \ ${_BAZEL_ARGS} --verbose_failures \ diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh index 39a15c4c37..197eef981d 100755 --- a/scripts/bootstrap/buildenv.sh +++ b/scripts/bootstrap/buildenv.sh @@ -77,22 +77,22 @@ darwin) fi ;; -msys*|mingw*) +msys*|mingw*|cygwin*) # Use a simplified platform string. - PLATFORM="mingw" + PLATFORM="windows" PATHSEP=";" # Find the latest available version of the SDK. - JAVA_HOME="${JAVA_HOME:-$(ls -d /c/Program\ Files/Java/jdk* | sort | tail -n 1)}" + JAVA_HOME="${JAVA_HOME:-$(ls -d C:/Program\ Files/Java/jdk* | sort | tail -n 1)}" # Replace backslashes with forward slashes. JAVA_HOME="${JAVA_HOME//\\//}" esac EXE_EXT="" -if [ "${PLATFORM}" == "mingw" ]; then +if [ "${PLATFORM}" == "windows" ]; then # Extension for executables. EXE_EXT=".exe" - # Fix TMPDIR on msys + # Fix TMPDIR on windows default_tmp=${TMP:-$(cygpath -mO)/Temp} TMPDIR=$(cygpath -ml "${TMPDIR:-$default_tmp}") fi @@ -235,13 +235,13 @@ function new_step() { } function git_sha1() { - if [ -x "$(which git || true)" ] && [ -d .git ]; then + if [ -x "$(which git 2>/dev/null)" ] && [ -d .git ]; then git rev-parse --short HEAD 2>/dev/null || true fi } function git_date() { - if [ -x "$(which git || true)" ] && [ -d .git ]; then + if [ -x "$(which git 2>/dev/null)" ] && [ -d .git ]; then git log -1 --pretty=%ai | cut -d " " -f 1 || true fi } diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh index 08687ac1c1..eec6123867 100755 --- a/scripts/bootstrap/compile.sh +++ b/scripts/bootstrap/compile.sh @@ -272,8 +272,7 @@ chmod 0755 ${ARCHIVE_DIR}/_embedded_binaries/process-wrapper${EXE_EXT} 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 @@ function build_jni() { 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 @@ else 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 @@ function run_bazel_jar() { --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 @@ function run_bazel_jar() { --startup_time=329 --extract_data_time=523 \ --rc_source=/dev/null --isatty=1 \ "${client_env[@]}" \ - --client_cwd=${PWD} \ + --client_cwd="$(get_cwd)" \ "${@}" } |