-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-cpu
executable file
·102 lines (93 loc) · 4.12 KB
/
build-cpu
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
92
93
94
95
96
97
98
99
100
101
102
# To do
# 1. Add control for how many threads during make
# 2. Add control for what OS build and thus which threading library (pthread/windows)
LIBRARY="multi_core"
DEBUG_FOLDER="debug-multi_core-cpu"
RELEASE_FOLDER="release-multi_core-cpu"
MAX_THREADS=$(nproc) # to speed up make
if [ "$#" == "0" ]
then
echo "USAGE: $0 <some sequence of options listed below>"
echo "(--c/--clean) : Erase ${DEBUG_FOLDER} and ${RELEASE_FOLDER}"
echo "(--cd/--clean-debug) : Erase ${DEBUG_FOLDER}"
echo "(--cr/--clean-release) : Erase${RELEASE_FOLDER}"
echo "(--bd/--build-debug) (--sh/--shared) (--st/--static) : Build ${LIBRARY} as static or shared library"
echo "(--bd/--build-debug) (--sh/--shared) (--st/--static) (--cc/--code-coverage) : Build ${LIBRARY} as static or shared library"
echo "(--br/--build-release) (--sh/--shared) (--st/--static) : Build ${LIBRARY} as static or shared library"
#possible future options here
fi
if [[ "$#" == "1" && ("$1" == "--c" || "$1" == "--clean") ]] ; then
echo "Removing ${DEBUG_FOLDER} and ${RELEASE_FOLDER}\n"
rm -rf ${DEBUG_FOLDER} ${RELEASE_FOLDER}
fi
if [[ "$#" == "1" && ("$1" == "--cd" || "$1" == "--clean-debug") ]] ; then
echo "Removing ${DEBUG_FOLDER}\n"
rm -rf ${DEBUG_FOLDER}
fi
if [[ "$#" == "1" && ("$1" == "--cr" || "$1" == "--clean-release") ]] ; then
echo "Removing ${RELEASE_FOLDER}\n"
rm -rf ${RELEASE_FOLDER}
fi
if [[ "$#" == "2" && ("$1" == "--bd" || "$1" == "--build-debug") ]] ; then
if [[ "$2" == "--sh" || "$2" == "--shared" ]]
then
mkdir -p ${DEBUG_FOLDER} && cd $_
printf "Proceding with cmake in debug mode\n"
cmake -DCMAKE_BUILD_TYPE=DEBUG -DBuildCuda=OFF -DBuildBenchmarks=OFF -DMultiCoreUseCodeCoverage=OFF -DBuildShared=ON ..
make -j $MAX_THREADS
printf "Finished make\n"
elif [[ "$2" == "--st" || "$2" == "--static" ]]
then
mkdir -p ${DEBUG_FOLDER} && cd $_
printf "Proceding with cmake in debug mode\n"
cmake -DCMAKE_BUILD_TYPE=DEBUG -DBuildCuda=OFF -DBuildBenchmarks=OFF -DMultiCoreUseCodeCoverage=OFF -DBuildShared=OFF ..
make -j $MAX_THREADS
printf "Finished make\n"
else
echo "Found an invalid build option: $2"
fi
fi
if [[ "$#" == "3" && ("$1" == "--bd" || "$1" == "--build-debug") ]] ; then
if [[ ("$2" == "--sh" || "$2" == "--shared") && ("$3" == "--cc" || "$3" == "--code-coverage") ]]
then
mkdir -p ${DEBUG_FOLDER} && cd $_
printf "Proceding with cmake in debug mode\n"
cmake -DCMAKE_BUILD_TYPE=DEBUG -DBuildCuda=OFF -DBuildBenchmarks=OFF -DBuildShared=ON -DMultiCoreUseCodeCoverage=ON ..
make -j $MAX_THREADS
make -j $MAX_THREADS multi_core_coverage
# strip extraneous files
lcov --remove multi_core_coverage.info "/usr/include/*" "$PWD/googlebench-src/*" "$PWD/googletest-src/*" -o multi_core_coverage.info
printf "Finished make\n"
elif [[ ("$2" == "--st" || "$2" == "--static") && ("$3" == "--cc" || "$3" == "--code-coverage") ]]
then
mkdir -p ${DEBUG_FOLDER} && cd $_
printf "Proceding with cmake in debug mode\n"
cmake -DCMAKE_BUILD_TYPE=DEBUG -DBuildCuda=OFF -DBuildBenchmarks=OFF -DBuildShared=OFF -DMultiCoreUseCodeCoverage=ON ..
make -j $MAX_THREADS
make -j $MAX_THREADS multi_core_coverage
# strip extraneous files
lcov --remove multi_core_coverage.info "/usr/include/*" "$PWD/googlebench-src/*" "$PWD/googletest-src/*" -o multi_core_coverage.info
printf "Finished make\n"
else
echo "Found an invalid build option: $2"
fi
fi
if [[ "$#" == "2" && ("$1" == "--br" || "$1" == "--build-release") ]] ; then
if [[ "$2" == "--sh" || "$2" == "--shared" ]]
then
mkdir -p ${RELEASE_FOLDER} && cd $_
printf "Proceding with cmake in debug mode\n"
cmake -DCMAKE_BUILD_TYPE=RELEASE -DBuildCuda=OFF -DBuildShared=ON -DMultiCoreUseCodeCoverage=OFF ..
make -j $MAX_THREADS
printf "Finished make\n"
elif [[ "$2" == "--st" || "$2" == "--static" ]]
then
mkdir -p ${RELEASE_FOLDER} && cd $_
printf "Proceding with cmake in debug mode\n"
cmake -DCMAKE_BUILD_TYPE=RELEASE -DBuildCuda=OFF -DBuildShared=OFF -DMultiCoreUseCodeCoverage=OFF ..
make -j $MAX_THREADS
printf "Finished make\n"
else
echo "Found an invalid build option: $2"
fi
fi