-
Notifications
You must be signed in to change notification settings - Fork 1
/
coverage.sh
executable file
·52 lines (44 loc) · 980 Bytes
/
coverage.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
#!/bin/bash
# get compiler
if [ $# -ne 1 ]; then
echo "Usage: $0 [gcc|clang]"
echo "Without specific compiler, use gcc"
compiler=gcc
else
compiler=$1
fi
if [[ "$compiler" == "gcc" ]]; then
export CC=gcc
export CXX=g++
elif [[ "$compiler" == "clang" ]]; then
export CC=clang
export CXX=clang++
else
echo "Invalid compiler: $compiler"
exit 1
fi
echo "use c compiler: $CC"
echo "use cxx compiler: $CXX"
# build
origin_dir="$(dirname "$(readlink -f "$0")")"
user_local_dir=$HOME/.local
build_dir=$origin_dir/build
dep_search_path=$user_local_dir/usr
cd $origin_dir
rm -rf $build_dir
mkdir -p $build_dir
cd $build_dir
cmake \
-S $origin_dir -B $build_dir \
-DCMAKE_BUILD_TYPE=Coverage \
-DCMAKE_PREFIX_PATH=$dep_search_path \
-DBUILD_SHARED_LIBS=ON \
-DMUGGLE_BUILD_STATIC_PIC=ON \
-DMUGGLE_BUILD_TRACE=OFF \
-DBUILD_TESTING=OFF \
-DMUGGLE_BUILD_EXAMPLE=OFF \
-DMUGGLE_BUILD_BENCHMARK=OFF \
-DMUGGLE_INSTALL_BIN=OFF
# run test & coverage
make
make coverage