-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathbuild.sh
executable file
·65 lines (53 loc) · 2.02 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
#!/bin/bash
CURDIR=$( cd "$( dirname "$0" )" && pwd );
echo -e "\033[0;32mBuild: ${CURDIR} \033[0m";
CMAKE="";
if [ "$( cmake --version 2>&1 | grep version | awk '{print $3 }' | awk -F '.' '{print $1}' )" == 3 ] ; then CMAKE=cmake; fi
if [ "$( cmake3 --version 2>&1 | grep version | awk '{print $3 }' | awk -F '.' '{print $1}' )" == 3 ] ; then CMAKE=cmake3; fi
if [ "$CMAKE" == "" ] ; then echo "Can't find cmake > 3.0"; exit; fi
case "$(uname -s)" in
Linux*) MACHINE=Linux;;
Darwin*) MACHINE=Mac;;
CYGWIN*) MACHINE=Cygwin;;
MINGW*) MACHINE=MinGw;;
MSYS*) MACHINE=MSys;;
*) MACHINE="UNKNOWN:$(uname -s)"
esac
MODE=Release;
FORMAT=0;
TIDY=0;
CMAKE_FLAGS=();
if [ "$MACHINE" == "Linux" ] ; then NUMBER_OF_PROCESSORS=$( grep -c ^processor /proc/cpuinfo ); fi
for i in "$@"
do
case "$i" in
doc ) make -C "${CURDIR}/doc/"; exit 0;;
debug ) MODE=Debug; CMAKE_FLAGS+=("-DCMAKE_C_FLAGS=\"-g3\"" "-DCMAKE_CXX_FLAGS=\"-g3\"" );;
release ) MODE=Release;;
profiling ) CMAKE_FLAGS+=("-DENABLE_PAPI_PROFILING=ON");;
format ) FORMAT=1;;
tidy ) TIDY=1;;
* ) echo "ERROR: arguments \"$i\" not supported: option = [debug|release]"; exit 1;;
esac
done
CMAKE_FLAGS+=( "-DCMAKE_BUILD_TYPE=$MODE" "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" );
echo -e "\033[0;32mCmake: ${CURDIR} \033[0m";
${CMAKE} -H${CURDIR} -B"${CURDIR}/build/${MODE}" "${CMAKE_FLAGS[@]}"
echo -e "\033[0;32mdone \033[0m";
if [ $FORMAT == 1 ]
then
echo -e "\033[0;32mFormat: ${CURDIR} \033[0m";
${CMAKE} --build "${CURDIR}/build/${MODE}" --target clang-format
echo -e "\033[0;32mdone \033[0m";
exit 0;
fi
if [ $TIDY == 1 ]
then
echo -e "\033[0;32mFormat: ${CURDIR} \033[0m";
${CMAKE} --build "${CURDIR}/build/${MODE}" --target clang-tidy
echo -e "\033[0;32mdone \033[0m";
exit 0;
fi
echo -e "\033[0;32mBuild: ${CURDIR} \033[0m";
if ! ${CMAKE} --build "${CURDIR}/build/${MODE}" --config ${MODE} --parallel "${NUMBER_OF_PROCESSORS}" ; then exit 1; fi
echo -e "\033[0;32mdone \033[0m";