forked from matthewbdwyer/tipc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·158 lines (132 loc) · 3.96 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·158 lines (132 loc) · 3.96 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
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
#!/bin/sh
set -ex
ANTLR_VERSION=4
JAVA_VERSION=11
# Default to LLVM 22, but allow callers/CI to override.
LLVM_VERSION=${LLVM_VERSION:-22}
ROOT_DIR=${GITHUB_WORKSPACE:-$(git rev-parse --show-toplevel)}
bootstrap_ubuntu_dependencies() {
[ -d /usr/share/keyrings ] || sudo mkdir -p /usr/share/keyrings
wget https://apt.corretto.aws/corretto.key
gpg --dearmor corretto.key
rm 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
rm 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
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
rm llvm.sh
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 \
jq \
doxygen
}
bootstrap_ubuntu_env() {
echo export LLVM_DIR="$(llvm-config-$LLVM_VERSION --prefix)/lib/cmake" >> ~/.bashrc
echo export TIPCLANG="$(llvm-config-$LLVM_VERSION --bindir)/clang" >> ~/.bashrc
echo export CC="$(llvm-config-$LLVM_VERSION --bindir)/clang" >> ~/.bashrc
echo export CXX="$(llvm-config-$LLVM_VERSION --bindir)/clang++" >> ~/.bashrc
}
bootstrap_ubuntu() {
bootstrap_ubuntu_dependencies
bootstrap_ubuntu_env
}
bootstrap_linux() {
. /etc/os-release
if [ "$ID" = ubuntu ] || [ "$ID" = pop ]; then
bootstrap_ubuntu
else
echo "$ID is not supported."
exit 1
fi
}
bootstrap_mac_env() {
case $SHELL in
*/zsh)
echo "export LLVM_DIR=$(brew --prefix llvm@$LLVM_VERSION)/lib/cmake" >> ~/.zshrc
echo "export TIPCLANG=$(brew --prefix llvm@$LLVM_VERSION)/bin/clang" >> ~/.zshrc
echo "export CC=$(brew --prefix llvm@$LLVM_VERSION)/bin/clang" >> ~/.zshrc
echo "export CXX=$(brew --prefix llvm@$LLVM_VERSION)/bin/clang++" >> ~/.zshrc
cat ~/.zshrc
;;
*/bash)
# The macOS github runner does not include zsh.
echo "export LLVM_DIR=$(brew --prefix llvm@$LLVM_VERSION)/lib/cmake" >> ~/.bashrc
echo "export TIPCLANG=$(brew --prefix llvm@$LLVM_VERSION)/bin/clang" >> ~/.bashrc
echo "export CC=$(brew --prefix llvm@$LLVM_VERSION)/bin/clang" >> ~/.bashrc
echo "export CXX=$(brew --prefix llvm@$LLVM_VERSION)/bin/clang++" >> ~/.bashrc
cat ~/.bashrc
;;
*)
echo "error: $SHELL is not supported."
esac
}
bootstrap_mac_dependencies() {
if ! [ -x "$(command -v brew)" ]; then
echoerr error: Homebrew is not installed.
exit 1
fi
brew install --cask corretto@$JAVA_VERSION
brew install \
git \
cmake \
pkg-config \
llvm@$LLVM_VERSION \
antlr \
lcov \
graphviz \
jq \
doxygen
}
bootstrap_mac() {
bootstrap_mac_dependencies
bootstrap_mac_env
}
bootstrap() {
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
bootstrap_linux;;
Darwin*)
bootstrap_mac;;
*)
echoerr "error: Script has not been implemented for: ${unameOut}."
exit 1
;;
esac
echo
echo '---------------------------------------------------------------------------------'
echo '* your rc has been updated - be sure to source the file or restart your shell. *'
echo '---------------------------------------------------------------------------------'
}
bootstrap