-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathbuild.sh
executable file
·140 lines (124 loc) · 3.79 KB
/
build.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
#!/bin/bash
# Formatted with `shfmt -i 4 -ci --w build.sh`
# Stop on error:
set -e
function print_help() {
cat <<EOF
Usage: ./build.sh [options]
Possible options:
-h, --help Display help
--deps-only Install dependencies only (don't build)
-p, --pybind Compile python bindings
-n, --no-tests Don't build tests
-u, --no-unpack Don't unpack datasets
-j[N], --parallel[N] The maximum number of concurrent processes for building
-d, --debug Set debug build type
-s[S], --sanitizer[=S] Build with sanitizer S (has effect only for debug build).
Possible values of S: ADDRESS, UB.
ADDRESS - Address Sanitizer
UB - Undefined Behavior Sanitizer
-l Use Link Time Optimization
-g Use GDB's debug information format
EOF
}
# TODO: use getopts or something else instead of bash
for i in "$@"; do
case $i in
# Install dependencies only (don't build)
--deps-only)
DEPS_ONLY=true
;;
# Compile python bindings
-p | --pybind)
PYBIND=true
;;
# Don't build tests
-n | --no-tests)
NO_TESTS=true
;;
# Don't unpack datasets
-u | --no-unpack)
NO_UNPACK=true
;;
# The maximum number of concurrent processes for building
-j* | --parallel*)
JOBS_OPTION=$i
;;
# Set debug build type
-d | --debug)
DEBUG_MODE=true
;;
# Build with sanitizer S, long option
--sanitizer=*)
SANITIZER="${i#*=}"
;;
# Build with sanitizer S, short option
-s*)
SANITIZER="${i#*s}"
;;
# Use Link Time Optimization
-l)
LTO=true
;;
# Use GDB's debug information format
-g)
GDB_DEBUG=true
;;
# Display help
-h | --help | *)
print_help
exit 0
;;
esac
done
mkdir -p lib
cd lib
if [[ ! -d "easyloggingpp" ]]; then
git clone https://github.com/amrayn/easyloggingpp/ --branch v9.97.0 --depth 1
fi
if [[ ! -d "better-enums" ]]; then
git clone https://github.com/aantron/better-enums.git --branch 0.11.3 --depth 1
fi
if [[ ! -d "pybind11" ]]; then
git clone https://github.com/pybind/pybind11.git --branch v2.13.4 --depth 1
fi
if [[ ! -d "emhash" ]]; then
git clone https://github.com/ktprime/emhash.git --depth 1
fi
if [[ ! -d "atomicbitvector" ]]; then
git clone https://github.com/ekg/atomicbitvector.git --depth 1
fi
if [[ ! -d "frozen" ]]; then
git clone https://github.com/serge-sans-paille/frozen.git --depth 1
fi
if [[ $NO_TESTS == true ]]; then
PREFIX="$PREFIX -D COMPILE_TESTS=OFF"
else
if [[ ! -d "googletest" ]]; then
git clone https://github.com/google/googletest/ --branch v1.14.0 --depth 1
fi
fi
if [[ $DEPS_ONLY == true ]]; then
exit 0
fi
if [[ $NO_UNPACK == true ]]; then
PREFIX="$PREFIX -D UNPACK_DATASETS=OFF"
fi
if [[ $PYBIND == true ]]; then
PREFIX="$PREFIX -D PYTHON=COMPILE -D COPY_PYTHON_EXAMPLES=ON"
fi
if [[ $LTO == true ]]; then
PREFIX="$PREFIX -D USE_LTO=ON"
fi
if [[ $GDB_DEBUG == true ]]; then
PREFIX="$PREFIX -D GDB_DEBUG=ON"
fi
if [[ $DEBUG_MODE != true ]]; then
PREFIX="$PREFIX -D CMAKE_BUILD_TYPE=Release"
fi
if [[ -n $SANITIZER ]]; then
PREFIX="$PREFIX -D SANITIZER=${SANITIZER}"
fi
cd ..
rm -f build/CMakeCache.txt
cmake -S . -B build $PREFIX -G Ninja && cmake --build build $JOBS_OPTION