Skip to content

Commit

Permalink
On Windows, build bazel.exe instead of just bazel.
Browse files Browse the repository at this point in the history
Needed for #276.

--
MOS_MIGRATED_REVID=114693711
  • Loading branch information
dslomov authored and damienmg committed Feb 16, 2016
1 parent fa465f6 commit 9d40a60
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
8 changes: 4 additions & 4 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ if [ $DO_COMPILE ]; then
new_step 'Building Bazel with Bazel'
display "."
log "Building output/bazel"
bazel_build src:bazel
cp -f bazel-bin/src/bazel output/bazel
chmod 0755 output/bazel
BAZEL=$(pwd)/output/bazel
bazel_build "src:bazel${EXE_EXT}"
cp -f "bazel-bin/src/bazel${EXE_EXT}" "output/bazel${EXE_EXT}"
chmod 0755 "output/bazel${EXE_EXT}"
BAZEL="$(pwd)/output/bazel${EXE_EXT}"
fi

#
Expand Down
7 changes: 7 additions & 0 deletions scripts/bootstrap/buildenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ if [ "${MACHINE_TYPE}" = 'arm' -o "${MACHINE_TYPE}" = 'armv7l' -o "${MACHINE_TYP
MACHINE_IS_ARM='yes'
fi

# Extension for executables.
EXE_EXT=""
case "${PLATFORM}" in
msys*|mingw*)
EXE_EXT=".exe"
esac

ATEXIT_=""
function atexit() {
ATEXIT_="$1; ${ATEXIT_}"
Expand Down
5 changes: 0 additions & 5 deletions scripts/bootstrap/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ unset _JAVA_OPTIONS

LDFLAGS=${LDFLAGS:-""}

# Extension for executables (.exe on Windows).
EXE_EXT=""

MSYS_DLLS=""
PATHSEP=":"

Expand Down Expand Up @@ -76,8 +73,6 @@ darwin)
msys*|mingw*)
# Use a simplified platform string.
PLATFORM="mingw"
# Workaround for msys issue which causes omission of std::to_string.
EXE_EXT=".exe"
PATHSEP=";"
# Find the latest available version of the SDK.
JAVA_HOME="${JAVA_HOME:-$(ls -d /c/Program\ Files/Java/jdk* | sort | tail -n 1)}"
Expand Down
20 changes: 20 additions & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,26 @@ genrule(
"_notools",
]]

# Build an executable named `bazel.exe`.
# Works on all platforms but only makes sense on Windows.
# Workaround for non-configurability of genrule's `outs` attribute.
[genrule(
name = "bazel-bin" + suffix + ".exe",
srcs = [":bazel-bin" + suffix],
outs = ["bazel" + suffix + ".exe"],
cmd = "cp $(location :bazel-bin" + suffix + ") $@",
executable = 1,
output_to_bindir = 1,
visibility = [
"//scripts:__pkg__", # For bash completion generation
"//scripts/packages:__pkg__", # For installer generation
"//src/test:__subpackages__", # For integration tests
],
) for suffix in [
"",
"_notools",
]]

config_setting(
name = "darwin",
values = {"cpu": "darwin"},
Expand Down

0 comments on commit 9d40a60

Please sign in to comment.