-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbuild.linux.sh
executable file
·156 lines (137 loc) · 4.04 KB
/
build.linux.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
#!/bin/bash -e
# Support build on Ubuntu (tested on Ubuntu 20.04 LTS)
# If the script doesn't work for you, look up manual steps in dev.md
# This script is basically automation script of dev.md
# It is supposed to run in same folder where the file lives (root).
# Unfortunately we still need to manually fix the GRPC issue listed in dev.md
if [ "$(uname -s)" != "Linux" ]; then
echo "Must be on Linux machine to run this script"
exit
fi
ROOT=$(git rev-parse --show-toplevel)
BUILD_DIR=$ROOT/build
# enter into nebula build folder
mkdir -p $BUILD_DIR && cd $BUILD_DIR
# before everything else, do apt update for a new imaged os
sudo apt update
# on a complete new system -
# before everything starts - need at least c compiler
sudo apt install -y build-essential libssl-dev cmake libboost-all-dev docker-compose
# packages could be installed by apt install
# "libfmt-dev"
aptGetInstallPackages=(
"libcurl4-gnutls-dev"
"libunwind-dev"
"libiberty-dev"
"gnutls-dev"
"libgcrypt-dev"
"libkrb5-dev"
"libldap-dev"
"librtmp-dev"
"libnghttp2-dev"
"libpsl-dev"
"libutf8proc-dev"
"libgflags-dev"
"libboost-dev"
"liblz4-dev"
"libzstd-dev"
"libbz2-dev"
"libsnappy-dev"
"liblzma-dev"
"libxml2-dev"
"autoconf"
"bison"
"flex"
"nlohmann-json3-dev"
)
# Install Prerequisites
# install cmake and gcc-10
(
if ! command -v cmake &> /dev/null
then
MJ_VER=3.19
MN_VER=3.19.2
wget https://cmake.org/files/v$MJ_VER/cmake-$MN_VER.tar.gz
tar -xzvf cmake-$MN_VER.tar.gz
cd cmake-$MN_VER/
./bootstrap
make -j$(nproc)
sudo make install
fi
# sudo apt update
sudo apt install -y gcc-10 g++-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 900 --slave /usr/bin/g++ g++ /usr/bin/g++-10
)
# loop through aptGetInstallPackages to install
for package in "${aptGetInstallPackages[@]}"; do
sudo apt install -y "$package"
done
# Install MBEDTLS
(
if [ -z "$(ls -A /usr/local/lib/libmbedtls.a)" ]; then
sudo rm -rf ./mbedtls
git clone --depth 1 --branch v3.0.0 https://github.com/ARMmbed/mbedtls.git
cd mbedtls && mkdir build && cd build
cmake -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC .. && make -j$(nproc)
sudo make install
fi
)
# Install LIBEVENT
(
if [ -z "$(ls -A /usr/local/lib/libevent.a)" ]; then
sudo rm -rf ./libevent
git clone --depth 1 --branch release-2.1.12-stable https://github.com/libevent/libevent.git
cd libevent
cmake . && make -j$(nproc)
sudo make install
fi
)
# Install Abseil
(
if [ -z "$(ls -A /usr/local/lib/libabsl_strings.a)" ]; then
sudo rm -rf ./abseil-cpp
git clone --depth 1 --branch 20211102.0 https://github.com/abseil/abseil-cpp.git
cd abseil-cpp && mkdir build && cd build
cmake -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DABSL_USES_STD_STRING_VIEW=ON -DABSL_USES_STD_OPTIONAL=ON -DCMAKE_CXX_STANDARD=11 ..
make -j$(nproc)
sudo make install
fi
)
# Install crc32c
(
if [ -z "$(ls -A /usr/local/lib/libcrc32c.a)" ]; then
sudo rm -rf ./crc32c
git clone --depth 1 --branch 1.1.1 https://github.com/google/crc32c.git
cd crc32c && mkdir build && cd build
cmake -DCRC32C_BUILD_TESTS=OFF -DCRC32C_BUILD_BENCHMARKS=OFF -DCRC32C_USE_GLOG=OFF ..
make -j$(nproc)
sudo make install
fi
)
# Install OpenSSL
SSL_ROOT=/usr/local/openssl
(
if [ -z "$(ls -A ${SSL_ROOT}/lib/libssl.a)" ]; then
sudo rm -rf ./openssl
git clone --depth 1 --branch OpenSSL_1_1_1k https://github.com/openssl/openssl.git
cd openssl && ./config --prefix=${SSL_ROOT} && make -j$(nproc) && sudo make install
fi
)
# build type from env name, default to release
# to run debug build, issue this `BUILD_TYPE=Debug ./build.sh` at nebula root
BTYPE=${BUILD_TYPE}
if [ "$BTYPE" == "" ]; then
BTYPE="Release"
fi
# flag to strip symbols
SYM=0
if [ "$BTYPE" == "Release" ]; then
SYM=1
fi
# run nebula cmake
echo "enter password for sudo..."
echo "-----------------------"
echo "build type: $BTYPE"
sudo cmake .. -DCMAKE_BUILD_TYPE=$BTYPE -DSYM=$SYM -DPPROF=2 -DOPENSSL_ROOT_DIR=${SSL_ROOT}
# execute make
sudo make -j$(nproc)