-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·71 lines (64 loc) · 1.45 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
#!/usr/bin/env bash
# Build the project.
#
# usage: ./build.sh <BUILD_TYPE> <TARGET>
#
# <BUILD_TYPE> must be debug, release, clean, doc.
# <TARGET> can be test, bench.
#
# To pass additional CMake arguments to the build procedure, edit build.config
# file.
#
# example usages:
#
# 1. Build tests
#
# ./build.sh release test
#
# 2. Build benchmarks
#
# ./build.sh release bench
#
# 3. Build documentation
#
# ./build.sh doc
build=$1
shift
target=$1
shift
if [[ ${build} == "debug" ]]; then
build="-DCMAKE_BUILD_TYPE=Debug"
elif [[ ${build} == "release" ]]; then
build="-DCMAKE_BUILD_TYPE=Release"
elif [[ ${build} == "clean" ]]; then
rm -rf build/CMakeFiles ||:
rm -rf build/CMakeCache.txt ||:
rm -rf build/cmake_install.cmake ||:
rm -rf build/Makefile ||:
rm -rf build/benchmark ||:
rm -rf build/tests ||:
rm -rf doc/build ||:
exit
elif [[ ${build} == "doc" ]]; then
doxygen doc/Doxyfile
exit
else
echo "Unknown build type: Use one of debug, release, clean, doc"
exit
fi
if [[ ${target} == "test" ]]; then
target="-DBUILD_TESTING=ON"
elif [[ ${target} == "bench" ]]; then
target="-DBUILD_BENCH=ON"
elif [[ ! -z ${target} ]]; then
echo "Unknown target: Use one of test, bench"
exit
fi
additional_flags=`cat build.config | grep -E '-' | tr '\n' ' ' | sed 's/.$//'`
echo 'Following additional flags will be applied:'
echo ${additional_flags} | tr ' ' '\n'
echo
mkdir -p build
cd build
cmake ${build} ${target} ${additional_flags} ..
make -j6