Skip to content

Commit

Permalink
Export the Bazelisk API once it is found. Subsequent calls cannot always
Browse files Browse the repository at this point in the history
see the runfiles for bazel_binary.
  • Loading branch information
cgrindel committed Dec 25, 2024
1 parent 4442f20 commit 23749c0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions bazel_integration_test/private/bazel_binaries_script.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# vi: ft=sh

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
Expand All @@ -8,16 +9,21 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
{ echo>&2 "ERROR: ${BASH_SOURCE[0]} cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---

export USE_BAZEL_VERSION="{version}"

# Need to write data here, the default is read-obly inside tests.
export BAZELISK_HOME="${PWD}"
# Need to write data here, the default is read-only inside tests.
if [[ -z "${BAZELISK_HOME:-}" ]]; then
export BAZELISK_HOME="${PWD}"
fi

# Find the bazelisk binary.
BINARY="$(rlocation {bazelisk})" || \
(echo >&2 "Failed to locate bazelisk at {bazelisk}" && exit 1)
# Find the bazelisk binary, if it has not already been found.
if [[ -z "${BAZELISK_BINARY:-}" ]]; then
BAZELISK_BINARY="$(rlocation {bazelisk})" || \
(echo >&2 "Failed to locate bazelisk at {bazelisk}" && exit 1)
export BAZELISK_BINARY
fi

exec "${BINARY}" ${BIT_STARTUP_OPTIONS:-} "$@"
exec "${BAZELISK_BINARY}" ${BIT_STARTUP_OPTIONS:-} "$@"

0 comments on commit 23749c0

Please sign in to comment.