bazel_test/tools/bazel_launcher.sh
2024-11-27 19:43:35 +00:00

26 lines
698 B
Bash
Executable File

#!/usr/bin/env bash
BAZEL_VERSION=7.4.1
BAZEL_URL=https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-x86_64
BAZEL_SHA256_CHECKSUM=c97f02133adce63f0c28678ac1f21d65fa8255c80429b588aeeba8a1fac6202b
REPO_ROOT=$(git rev-parse --show-toplevel)
OUT_PATH="${REPO_ROOT}/bazel-${BAZEL_VERSION}"
BAZEL_BIN="${OUT_PATH}/bazel"
if [ ! -f "${BAZEL_BIN}" ]; then
mkdir -p "${OUT_PATH}"
fi
if [ ! -f "${BAZEL_BIN}" ]; then
curl -L -o "${BAZEL_BIN}" "${BAZEL_URL}"
chmod +x "${BAZEL_BIN}"
fi
sha256sum ${BAZEL_BIN} | grep -q ${BAZEL_SHA256_CHECKSUM}
if [ $? -ne 0 ]; then
echo "bazel binary checksum mismatch, exiting"
exit 1
fi
"${BAZEL_BIN}" "${@}"