-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·58 lines (49 loc) · 978 Bytes
/
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
#!/usr/bin/env bash
clean=0
tests=""
valgrind=""
while [[ $# -gt 0 ]]; do
case $1 in
-c|--clean)
echo "Clean Build"
clean=1
shift
;;
-t|--tests)
echo "Running Tests"
tests="run_tests"
shift
;;
-v|--valgrind)
echo "Running valgrind"
shift
valgrind="$1"
shift
;;
*)
echo "Unknown option: $1"
shift
;;
esac
done
if [ ! -d "build" ]; then
clean=1
fi
if [ $clean == 1 ]; then
rm -rf build
cmake -S ./ -B build
fi
if [ $(basename $(pwd)) != "build" ]; then
pushd "build"
fi
if [ "${tests}" != "" ]; then
make -j$(nproc) "${tests}"
else
make -j$(nproc)
fi
if [ "${valgrind}" != "" ]; then
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./$(echo $valgrind)
fi
if [ $(basename $(pwd)) != "build" ]; then
popd
fi