forked from modular/modular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbazelw
More file actions
executable file
·57 lines (47 loc) · 1.64 KB
/
bazelw
File metadata and controls
executable file
·57 lines (47 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -euo pipefail
readonly version="1.21.0"
arch="$(uname -m)"
if [[ "$arch" == "aarch64" || "$arch" == "arm64" ]]; then
readonly bazel_arch="arm64"
else
readonly bazel_arch="amd64"
fi
if [[ $OSTYPE == darwin* ]]; then
readonly platform=darwin-arm64
readonly sha="17529faeed52219ee170d59bd820c401f1645a95f95ee4ac3ebd06972edfb6ff"
elif [[ $OSTYPE == linux* ]]; then
readonly platform=linux-"$bazel_arch"
if [[ "$bazel_arch" == "amd64" ]]; then
readonly sha="655a5c675dacf3b7ef4970688b6a54598aa30cbaa0b9e717cd1412c1ef9ec5a7"
else
readonly sha="ff793b461968e30d9f954c080f4acaa557edbdeab1ce276c02e4929b767ead66"
fi
else
echo "error: unsupported platform $OSTYPE" >&2
exit 1
fi
readonly url="https://github.com/bazelbuild/bazelisk/releases/download/v$version/bazelisk-$platform"
script_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly executable="$script_root/build/bazelisk-$version-$platform"
if [[ ! -x "$executable" ]]; then
echo "Installing bazelisk..." >&2
mkdir -p "$(dirname "$executable")"
download_bazelisk() {
curl --fail -L --retry 5 --retry-connrefused --silent --progress-bar \
--output "$executable" "$url"
}
download_bazelisk || download_bazelisk
if echo "$sha $executable" | shasum --check --status; then
chmod +x "$executable"
else
echo "error: bazelisk sha mismatch" >&2
rm -f "$executable"
exit 1
fi
fi
# Set BAZEL to the executable path so the rules_go dependency can reference it.
# Without this, rules_go will likely fail in CI with the following error:
# exec: "bazel": executable file not found in $PATH
export BAZEL="$executable"
exec "$executable" "$@"