-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·148 lines (131 loc) · 4.24 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·148 lines (131 loc) · 4.24 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
#!/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
-p, --pybind Compile python bindings
-n, --no-tests Don't build tests
-b --benchmark Build benchmarks
-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
-f, --no-fetch-datasets Don't fetch datasets for tests or benchmarks
-L[LEVEL] --log-level[=LEVEL] Set log level (TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL)
-C[OPT] --cmake-opt[=OPT] Forward OPT to CMake
-B[OPT] --build-opt[=OPT] Forward OPT to build system
EOF
}
GDB_DEBUG=true
# TODO: use getopts or something else instead of bash
for i in "$@"; do
case $i in
# Compile python bindings
-p | --pybind)
PYBIND=true
;;
# Don't build tests
-n | --no-tests)
NO_TESTS=true
;;
# Build benchmarks
-b | --benchmark)
BENCHMARK=true
;;
# The maximum number of concurrent processes for building
-j* | --parallel*)
BUILD_OPTS="$BUILD_OPTS $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
;;
# Don't fetch datasets for tests or benchmarks
-f | --no-fetch-datasets)
NO_FETCH_DATASETS=true
;;
# Set log level, long option
--log-level=*)
LOG_LEVEL="${i#*=}"
;;
# Set log level, short option
-L*)
LOG_LEVEL="${i#*L}"
;;
# Forward option to CMake, long option
--cmake-opt=*)
CMAKE_OPTS="$CMAKE_OPTS ${i#*=}"
;;
# Forward option to CMake, short option
-C*)
CMAKE_OPTS="$CMAKE_OPTS ${i#*C}"
;;
# Forward option to build system, long option
--build-opt=*)
BUILD_OPTS="$BUILD_OPTS ${i#*=}"
;;
# Forward option to build system, short option
-B*)
BUILD_OPTS="$BUILD_OPTS ${i#*B}"
;;
# Display help
-h | --help | *)
print_help
exit 0
;;
esac
done
CMAKE_OPTS="$CMAKE_OPTS -G Ninja"
if [[ $NO_TESTS == true ]]; then
CMAKE_OPTS="$CMAKE_OPTS -D DESBORDANTE_BUILD_TESTS=OFF"
fi
if [[ $BENCHMARK == true ]]; then
CMAKE_OPTS="$CMAKE_OPTS -D DESBORDANTE_BUILD_BENCHMARKS=ON"
fi
if [[ $PYBIND == true ]]; then
CMAKE_OPTS="$CMAKE_OPTS -D DESBORDANTE_BINDINGS=BUILD"
fi
if [[ $LTO == true ]]; then
CMAKE_OPTS="$CMAKE_OPTS -D DESBORDANTE_USE_LTO=ON"
fi
if [[ $GDB_DEBUG == true ]]; then
CMAKE_OPTS="$CMAKE_OPTS -D DESBORDANTE_GDB_SYMBOLS=ON"
fi
if [[ $NO_FETCH_DATASETS == true ]]; then
CMAKE_OPTS="$CMAKE_OPTS -D DESBORDANTE_FETCH_DATASETS=OFF"
fi
if [[ $DEBUG_MODE != true ]]; then
CMAKE_OPTS="$CMAKE_OPTS -D CMAKE_BUILD_TYPE=Release"
fi
if [[ -n $SANITIZER ]]; then
CMAKE_OPTS="$CMAKE_OPTS -D DESBORDANTE_SANITIZER=${SANITIZER}"
fi
if [[ -n $LOG_LEVEL ]]; then
CMAKE_OPTS="$CMAKE_OPTS -D DESBORDANTE_LOG_LEVEL=${LOG_LEVEL}"
fi
rm -f build/CMakeCache.txt
cmake -S . -B build $CMAKE_OPTS && cmake --build build $BUILD_OPTS