-
Notifications
You must be signed in to change notification settings - Fork 0
/
bazelw
executable file
·74 lines (65 loc) · 1.68 KB
/
bazelw
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env sh
# https://github.com/bazelbuild/bazelisk/releases
BAZELISK_VERSION="v1.10.1"
BAZELISK_DIR=".bazel"
##############################################################################
##
## Bazel start up script for UN*X (based on gradlew script from gradle wrapper project)
##
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
die () {
echo
echo "$*"
echo
exit 1
}
## Determine OS.
darwin=false
linux=false
case "`uname`" in
Darwin* )
darwin=true
;;
Linux* )
linux=true
;;
esac
BINARY_PATH=""
if $darwin; then
BINARY_PATH=bazelisk-darwin-amd64
elif $linux; then
BINARY_PATH=bazelisk-linux-amd64
else
die "UNSUPPORTED OS! Command 'uname' says: `uname`. 'darwin' = $darwin and 'linux' = $linux"
fi
FULL_BINARY_PATH="$APP_HOME/${BAZELISK_DIR}/$BINARY_PATH"
if [ ! -f "$FULL_BINARY_PATH" ]; then
BAZELISK_URL="https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/${BINARY_PATH}"
echo "Downloading ${BAZELISK_URL}"
mkdir -p "$(dirname "$FULL_BINARY_PATH")"
if command -v wget >/dev/null 2>&1; then
wget -q -O "${FULL_BINARY_PATH}" "${BAZELISK_URL}"
else
curl -s -o "${FULL_BINARY_PATH}" -L "${BAZELISK_URL}"
fi
chmod +x "$FULL_BINARY_PATH"
fi
exec "$FULL_BINARY_PATH" "$@"