-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathinstall.sh
159 lines (127 loc) · 4.01 KB
/
install.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
os=$(uname -s)
arch=$(uname -m)
executable_url=""
if [ "$os" = "Darwin" ] && [ "$arch" = "arm64" ]; then
executable_url="https://github.com/vekatze/neut/releases/latest/download/neut-arm64-darwin"
elif [ "$os" = "Linux" ] && [ "$arch" = "x86_64" ]; then
executable_url="https://github.com/vekatze/neut/releases/latest/download/neut-amd64-linux"
elif [ "$os" = "Linux" ] && [ "$arch" = "aarch64" ]; then
executable_url="https://github.com/vekatze/neut/releases/latest/download/neut-arm64-linux"
else
echo "unsupported platform: $os ($arch)"
exit 1
fi
HAS_CLANG=0
HAS_CURL=0
HAS_TAR=0
HAS_ZSTD=0
ESC=$(printf '\033')
RED="${ESC}[1;31m%s${ESC}[m"
MAGENTA="${ESC}[1;35m%s${ESC}[m"
BLUE="${ESC}[1;34m%s${ESC}[m"
CYAN="${ESC}[1;36m%s${ESC}[m"
clangs=(
"clang"
"clang-15"
"clang-16"
"clang-17"
"clang-18"
"clang-19"
"clang-20"
)
for CLANG in "${clangs[@]}"; do
if command -v $CLANG >/dev/null 2>&1; then
version=$(echo | $CLANG -dM -E - | grep __clang_major__ | awk '{print $3}')
if [ $version -ge 15 ]; then
HAS_CLANG=1
break
fi
fi
done
if command -v curl >/dev/null 2>&1; then
HAS_CURL=1
fi
if command -v tar >/dev/null 2>&1; then
HAS_TAR=1
fi
if command -v zstd >/dev/null 2>&1; then
HAS_ZSTD=1
fi
if [ $HAS_CLANG -eq 0 ]; then
printf $MAGENTA "warning: "
echo "\`clang\` (>= 15.0.0) is missing"
fi
if [ $HAS_TAR -eq 0 ]; then
printf $MAGENTA "warning: "
echo "\`tar\` is missing"
fi
if [ $HAS_CURL -eq 0 ]; then
printf $MAGENTA "warning: "
echo "\`curl\` is missing"
fi
if [ $HAS_ZSTD -eq 0 ]; then
printf $MAGENTA "warning: "
echo "\`zstd\` is missing"
fi
if [ $HAS_CLANG -eq 0 ] || [ $HAS_TAR -eq 0 ] || [ $HAS_CURL -eq 0 ] || [ $HAS_ZSTD -eq 0 ]; then
if command -v apt-get >/dev/null 2>&1; then
printf $BLUE "note: "
echo "You can install all the dependencies by:"
echo " apt-get install -y --no-install-recommends curl tar zstd lsb-release wget software-properties-common gnupg && bash -c \"\$(wget -O - https://apt.llvm.org/llvm.sh)\" -s 16"
# packages from llvm.sh can be uninstalled by: apt remove clang-16 lldb-16 lld-16 clangd-16
elif command -v pacman >/dev/null 2>&1; then
printf $BLUE "note: "
echo "You can install all the dependencies by:"
echo " pacman -S curl tar zstd clang"
elif [ "$os" = "Darwin" ] && command -v brew >/dev/null 2>&1; then
os_version=$(sw_vers -productVersion | awk -F . '{print $1}')
if [ $os_version -ge 14 ]; then # 14 == Sonoma
printf $BLUE "note: "
echo "You can install all the dependencies by:"
echo " brew install zstd"
else
printf $BLUE "note: "
echo "You can install all the dependencies by:"
echo " brew install llvm zstd"
fi
fi
printf $BLUE "note: "
echo "Please re-run this script after installing all the dependencies."
exit 1
fi
printf $BLUE "✓ "
echo "found all the dependencies."
echo ""
target_dir="$HOME/.local/bin"
mkdir -p $target_dir
printf $BLUE "note: "
echo "downloading the compiler..."
echo ""
curl -SL -o $target_dir/neut $executable_url
chmod +x $target_dir/neut
echo ""
printf $BLUE "✓ "
printf "installed the compiler to "
printf $CYAN "$HOME/.local/bin/neut"
echo ""
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
echo ""
printf $MAGENTA "warning: "
echo "~/.local/bin is not in your \$PATH. "
fi
echo ""
printf $BLUE "note: "
echo "please restart your shell after adding the following environment variables to your shell config:"
echo ""
echo "export NEUT_CORE_MODULE_URL=\"https://github.com/vekatze/neut-core/raw/main/archive/0-50-46.tar.zst\""
echo "export NEUT_CORE_MODULE_DIGEST=\"3PRPyylEh5TJ7GbaO-eGj3SZaFAa9vSaDur94E09s88\""
if command -v apt-get >/dev/null 2>&1; then
echo "export NEUT_CLANG=$CLANG"
elif [ "$os" = "Darwin" ] && command -v brew >/dev/null 2>&1 && [ $HAS_CLANG -eq 0 ]; then
echo "export NEUT_CLANG=$(brew --prefix)/opt/llvm/bin/clang-N # N == 15, 16, etc."
fi
echo ""
printf $BLUE "note: "
echo "you can run \`neut version\` to see if the compiler is installed correctly."
echo ""