-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·150 lines (118 loc) · 3.25 KB
/
bootstrap.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
#!/usr/bin/env bash
set -ex
declare -r ANTLR_VERSION=4
declare -r JAVA_VERSION=11
declare -r LLVM_VERSION=14
declare -r ROOT_DIR=${GITHUB_WORKSPACE:-$(git rev-parse --show-toplevel)}
echogreen() {
local green=$(tput setaf 2)
local reset=$(tput sgr0)
echo "${green}${@}${reset}"
}
echoerr() {
local red=$(tput setaf 1)
local reset=$(tput sgr0)
echo "${red}${@}${reset}" 1>&2;
echo "$@" 1>&2;
}
bootstrap_ubuntu_dependencies() {
[ -d /usr/share/keyrings ] || sudo mkdir -p /usr/share/keyrings
wget https://apt.corretto.aws/corretto.key
gpg --dearmor corretto.key
sudo mv corretto.key.gpg /usr/share/keyrings/amazon-corretto-${JAVA_VERSION}-keyring.gpg
sudo cp ${ROOT_DIR}/bin/apt/amazon-corretto-${JAVA_VERSION}.sources /etc/apt/sources.list.d/
sudo apt -y update
wget https://apt.kitware.com/kitware-archive.sh
chmod +x kitware-archive.sh
sudo ./kitware-archive.sh
sudo apt -y install \
java-$JAVA_VERSION-amazon-corretto-jdk \
git \
cmake \
pkg-config \
uuid-dev \
antlr$ANTLR_VERSION \
zlib1g-dev \
lcov
if [ "$VERSION_ID" = "18.04" ]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
fi
wget https://apt.llvm.org/llvm.sh
sed -i -E 's,Ubuntu_(.*),&\n Pop_\1,g' llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh $LLVM_VERSION
sudo apt -y install \
libllvm-$LLVM_VERSION-ocaml-dev \
libllvm$LLVM_VERSION \
llvm-$LLVM_VERSION \
llvm-$LLVM_VERSION-dev \
llvm-$LLVM_VERSION-doc \
llvm-$LLVM_VERSION-examples \
llvm-$LLVM_VERSION-runtime
sudo apt -y install \
clang-tools-$LLVM_VERSION \
clang-$LLVM_VERSION-doc \
libclang-common-$LLVM_VERSION-dev \
libclang-$LLVM_VERSION-dev \
libclang1-$LLVM_VERSION \
clang-format-$LLVM_VERSION \
python3-clang-$LLVM_VERSION \
graphviz
}
bootstrap_ubuntu_env() {
echo export TIPCLANG=$(which clang-$LLVM_VERSION) >> ~/.bashrc
}
bootstrap_ubuntu() {
bootstrap_ubuntu_dependencies
bootstrap_ubuntu_env
}
bootstrap_linux() {
. /etc/os-release
if [ $ID == ubuntu -o $ID == pop ]; then
bootstrap_ubuntu
else
echoerr $ID is not supported.
exit 1
fi
}
bootstrap_mac_env() {
echo export LLVM_DIR=$(brew --prefix llvm@$LLVM_VERSION)/lib/cmake >> ~/.bashrc
echo export TIPCLANG=$(brew --prefix llvm@$LLVM_VERSION)/bin/clang >> ~/.bashrc
}
bootstrap_mac_dependencies() {
if ! [ -x "$(command -v brew)" ]; then
echoerr error: Homebrew is not installed.
exit 1
fi
brew install homebrew/cask-versions/corretto$JAVA_VERSION
brew install \
git \
cmake \
pkg-config \
llvm@$LLVM_VERSION \
antlr@$ANTLR_VERSION \
lcov \
graphviz
}
bootstrap_mac() {
bootstrap_mac_dependencies
bootstrap_mac_env
}
bootstrap() {
local unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
bootstrap_linux;;
Darwin*)
bootstrap_mac;;
*)
echoerr error: Script has not been implemented for: ${unameOut}.
exit 1
;;
esac
echogreen
echogreen '--------------------------------------------------------------------------------'
echogreen '* bashrc has been updated - be sure to source the file or restart your shell. *'
echogreen '--------------------------------------------------------------------------------'
}
bootstrap