-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
executable file
·50 lines (49 loc) · 1006 Bytes
/
compile.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
#!/bin/bash
build_folder="build"
cmake_args="-DCMAKE_EXPORT_COMPILE_COMMANDS=true -DCMAKE_BUILD_TYPE=RelWithDebInfo"
cxx_args="-g"
do_sanitize="false"
do_build="false"
while getopts "rcvlbs" opt; do
case $opt in
r)
do_reset=true
;;
c)
do_configure=true
;;
v)
cmake_args+=" -DCMAKE_VERBOSE_MAKEFILE=ON"
;;
l)
cmake_args+=" -DLOG_LEVEL=4"
;;
b)
do_build="true"
;;
s)
do_sanitize="true"
cxx_args+=" -fsanitize=address"
;;
*)
echo "invalid parameter: $opt"
;;
esac
done
if [ -n "$do_reset" ]; then
rm -rf "$build_folder"
echo "Deleted build folder"
fi
if [ ! -d "$build_folder" ]; then
mkdir "$build_folder"
if [ -n "$do_configure" ]; then
cd "$build_folder"
CXXFLAGS="$cxx_args" cmake $cmake_args ..
cp compile_commands.json ..
cd ..
fi
fi
if [ "$do_build" = "true" ]; then
cd "$build_folder"
make -j
fi