-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·91 lines (78 loc) · 1.87 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
#!/usr/bin/bash
# --- Defaults ---
BUILD_TYPE="Release"
BUILD_DOCS="ON"
ENABLE_TESTING="OFF"
ENABLE_TRACE="OFF"
ENABLE_TRACE_ESSENTIAL="OFF"
RUN_PERF_STAT="OFF"
RUN_PERF_RECORD="OFF"
RUN_MEMCHECK="OFF"
# --- Defaults ---
set -e
for i in "$@"
do
case $i in
-d|--debug) BUILD_TYPE="Debug";;
-r|--release) BUILD_TYPE="Release";;
-T|--tests) ENABLE_TESTING="ON";;
--trace) ENABLE_TRACE="ON";;
--trace-essential) ENABLE_TRACE_ESSENTIAL="ON";;
-P|--perf-stat) RUN_PERF_STAT="ON";;
--perf-record) RUN_PERF_RECORD="ON";;
-V|--memcheck) RUN_MEMCHECK="ON";;
*)
echo "$0: unknown option \"$i\""
exit 1
;;
esac
done
mkdir -p bin
mkdir -p build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DENABLE_TESTING=$ENABLE_TESTING \
-DENABLE_TRACE=$ENABLE_TRACE \
-DENABLE_TRACE_ESSENTIAL=$ENABLE_TRACE_ESSENTIAL
make -j8
mv compile_commands.json .. || true
cp ../static/* ../bin/
cp ../static/* ../build/
if [ "$ENABLE_TESTING" = "ON" ]
then
cd tests
ctest --output-on-failure
cd ..
fi
cd ..
if [ "$BUILD_DOCS" = "ON" ]
then
cp extern/doxygen_theme_flat_design/img/* .doxygen/html/
doxygen Doxyfile
fi
if ! command -v perf &> /dev/null
then
echo "perf could not be found."
else
if [ "$RUN_PERF_STAT" = "ON" ]
then
perf stat --repeat=5 --table --detailed bin/buddy8800 tests/res/diag2.com 0x100
fi
if [ "$RUN_PERF_RECORD" = "ON" ]
then
perf record -F 8000 -g -- bin/buddy8800 tests/res/diag2.com 0x100
perf report
rm perf.data
fi
fi
if ! command -v valgrind &> /dev/null
then
echo "valgrind could not be found."
else
if [ "$RUN_MEMCHECK" = "ON" ]
then
#valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes bin/buddy8800 tests/res/diag2.com
valgrind --tool=memcheck bin/buddy8800 "tests/res/cpudiag.bin"
fi
fi