Ninja (#391)
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:
parent
d0dfa242b2
commit
4c8dbdbb85
33
build.sh
33
build.sh
|
@ -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
31
test.sh
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue