forked from bang-olufsen/yash
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·39 lines (31 loc) · 996 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
#!/bin/bash
set -e
CMAKE_ARGS="-DBUILD_TEST=1"
if [ "$1" = "example" ]; then
CMAKE_ARGS="-DBUILD_EXAMPLE=1"
fi
if [ "$(uname)" = "Linux" ]; then
CPU_CORES="$(nproc)"
TOOLCHAIN_FILE="-DCMAKE_TOOLCHAIN_FILE=cmake/gcc.cmake"
elif [ "$(uname)" = "Darwin" ]; then
CPU_CORES="$(sysctl -n hw.ncpu)"
TOOLCHAIN_FILE="-DCMAKE_TOOLCHAIN_FILE=cmake/clang.cmake"
fi
mkdir -p .build-external; pushd .build-external
cmake ../external
make -j "$CPU_CORES"
popd
arch_name="$(uname -m)"
mkdir -p ".build-$arch_name"; pushd ".build-$arch_name"
cmake "$CMAKE_ARGS" "$TOOLCHAIN_FILE" ..
make -j "$CPU_CORES"
if [ "$1" = "coverage" ]; then
lcov -q -c -i -d . -o base.info
ctest --verbose
lcov -q -c -d . -o test.info 2>/dev/null
lcov -q -a base.info -a test.info > total.info
lcov -q -r total.info "*usr/include/*" "*CMakeFiles*" "*Catch2*" "*turtle*" "*/test/*" "*src/*" -o coverage.info
genhtml -o coverage coverage.info
echo "Coverage report can be found in $(pwd)/coverage"
fi
popd