Use ninja to build if found on system (in /bin/ninja)
Make make simulate ninja's default parallelism

Should help with travis_ci as default build environments have 2 cores.
This commit is contained in:
interfector18 2020-03-16 17:54:30 +01:00 committed by GitHub
parent d0dfa242b2
commit 4c8dbdbb85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 7 deletions

View File

@ -28,9 +28,9 @@ function build_drogon() {
echo "Start building drogon ..."
if [ $1 -eq 1 ]; then
cmake .. -DBUILD_TESTING=YES
cmake .. -DBUILD_TESTING=YES $cmake_gen
else
cmake ..
cmake .. $cmake_gen
fi
#If errors then exit
@ -38,7 +38,7 @@ function build_drogon() {
exit -1
fi
make
$make_program $make_flags
#If errors then exit
if [ "$?" != "0" ]; then
@ -46,13 +46,38 @@ function build_drogon() {
fi
echo "Installing ..."
sudo make install
sudo $make_program install
#Go back to the current directory
cd $current_dir
#Ok!
}
make_program=make
make_flags=''
cmake_gen=''
parallel=1
# simulate ninja's parallelism
case $(nproc) in
1)
parallel=$(( $(nproc) + 1 ))
;;
2)
parallel=$(( $(nproc) + 1 ))
;;
*)
parallel=$(( $(nproc) + 2 ))
;;
esac
if [ -f /bin/ninja ]; then
make_program=ninja
cmake_gen='-G Ninja'
else
make_flags="$make_flags -j$parallel"
fi
if [ "$1" = "-t" ]; then
build_drogon 1
else

31
test.sh
View File

@ -4,6 +4,31 @@ drogon_ctl_exec=`pwd`/build/drogon_ctl/drogon_ctl
echo ${drogon_ctl_exec}
cd build/examples/
make_program=make
make_flags=''
cmake_gen=''
parallel=1
# simulate ninja's parallelism
case $(nproc) in
1)
parallel=$(( $(nproc) + 1 ))
;;
2)
parallel=$(( $(nproc) + 1 ))
;;
*)
parallel=$(( $(nproc) + 2 ))
;;
esac
if [ -f /bin/ninja ]; then
make_program=ninja
cmake_gen='-G Ninja'
else
make_flags="$make_flags -j$parallel"
fi
#Make webapp run as a daemon
sed -i -e "s/\"run_as_daemon.*$/\"run_as_daemon\": true\,/" config.example.json
sed -i -e "s/\"relaunch_on_error.*$/\"relaunch_on_error\": true\,/" config.example.json
@ -93,14 +118,14 @@ if [ ! -f "Test_TestPlugin.h" -o ! -f "Test_TestPlugin.cc" ]; then
fi
cd ../build
cmake ..
cmake .. $cmake_gen
if [ $? -ne 0 ]; then
echo "Error in testing"
exit -1
fi
make
$make_program $make_flags
if [ $? -ne 0 ]; then
echo "Error in testing"
@ -119,7 +144,7 @@ if [ "$1" = "-t" ]; then
#unit testing
cd ../
echo "Unit testing"
make test
$make_program $make_flags test
if [ $? -ne 0 ]; then
echo "Error in unit testing"
exit -1