-
Notifications
You must be signed in to change notification settings - Fork 0
/
mold.sh
executable file
·55 lines (47 loc) · 1.27 KB
/
mold.sh
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
#!/bin/sh
# This script will download the mold executable from $URL as $EXE, then pass
# all arguments through to it. This simplifies usage on CI/CD platforms as well
# as for users who haven't installed mold yet.
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
case "$(uname -s)" in
Linux*) PLATFORM=linux;;
Darwin*) PLATFORM=mac;;
CYGWIN*) PLATFORM=windows;;
MINGW*) PLATFORM=windows;;
*) PLATFORM=""
esac
if [ -z "$PLATFORM" ]; then
printf $RED"Error:"$NC" could not determine platform: $(uname -s)\n"
exit 1
fi
EXT=""
if [ "$PLATFORM" = "windows" ]; then
EXT=".exe"
fi
VER="0.7.0"
EXE="./.mold-$VER"
URL="https://github.com/xtfc/mold/releases/download/v$VER/mold-v$VER-$PLATFORM$EXT"
if [ ! -f $EXE ]; then
# decide whether we can use curl or wget
if hash curl 2>/dev/null; then
CMD="curl -sSfL $URL -o $EXE"
elif hash wget 2>/dev/null; then
CMD="wget -q $URL -O $EXE"
else
printf $RED"Error:"$NC" could not find curl or wget\n"
exit 1
fi
# download or exit
printf $GREEN" Downloading"$NC" mold v$VER\r"
if $CMD; then
chmod +x $EXE
printf $GREEN" Downloaded"$NC" mold v$VER\n"
else
printf $RED"Error:"$NC" could not download mold v$VER\n"
rm $EXE
exit 1
fi
fi
$EXE $@