2014-12-31 18:32:25 -04:00
|
|
|
#!/bin/bash
|
|
|
|
# useful script to test all the different build types that we support.
|
|
|
|
# This helps when doing large merges
|
|
|
|
# Andrew Tridgell, November 2011
|
|
|
|
|
2015-04-05 16:24:54 -03:00
|
|
|
. ~/.profile
|
|
|
|
|
2017-07-17 11:03:30 -03:00
|
|
|
set -ex
|
|
|
|
|
2016-01-07 12:11:34 -04:00
|
|
|
# CXX and CC are exported by default by travis
|
2016-03-08 20:52:33 -04:00
|
|
|
c_compiler=${CC:-gcc}
|
|
|
|
cxx_compiler=${CXX:-g++}
|
2016-01-07 12:11:34 -04:00
|
|
|
unset CXX CC
|
|
|
|
|
2016-04-15 11:53:10 -03:00
|
|
|
export BUILDROOT=/tmp/ci.build
|
2016-01-18 21:28:04 -04:00
|
|
|
rm -rf $BUILDROOT
|
2016-04-15 11:53:10 -03:00
|
|
|
export GIT_VERSION="ci_test"
|
|
|
|
export NUTTX_GIT_VERSION="ci_test"
|
|
|
|
export PX4_GIT_VERSION="ci_test"
|
|
|
|
export CCACHE_SLOPPINESS="include_file_ctime,include_file_mtime"
|
2016-01-18 21:28:04 -04:00
|
|
|
|
2016-05-11 17:09:43 -03:00
|
|
|
# If CI_BUILD_TARGET is not set, build 3 different ones
|
2016-01-18 15:37:53 -04:00
|
|
|
if [ -z "$CI_BUILD_TARGET" ]; then
|
2016-05-11 17:09:43 -03:00
|
|
|
CI_BUILD_TARGET="sitl linux px4-v2"
|
2015-06-15 22:03:23 -03:00
|
|
|
fi
|
2015-06-11 19:56:15 -03:00
|
|
|
|
2016-05-17 02:16:42 -03:00
|
|
|
if [[ "$CI_BUILD_TARGET" == *"px4"* ]]; then
|
2017-08-24 21:11:57 -03:00
|
|
|
export CCACHE_MAXSIZE="250M"
|
2016-05-25 14:23:36 -03:00
|
|
|
elif [[ "$CI_BUILD_TARGET" == "sitltest" ]]; then
|
2017-08-24 21:11:57 -03:00
|
|
|
export CCACHE_MAXSIZE="20M"
|
2016-05-17 02:16:42 -03:00
|
|
|
else
|
2017-08-24 21:11:57 -03:00
|
|
|
export CCACHE_MAXSIZE="150M"
|
2016-05-17 02:16:42 -03:00
|
|
|
fi
|
|
|
|
|
2016-05-11 17:09:43 -03:00
|
|
|
declare -A waf_supported_boards
|
|
|
|
|
2015-12-07 14:33:25 -04:00
|
|
|
waf=modules/waf/waf-light
|
|
|
|
|
2015-11-27 14:50:45 -04:00
|
|
|
# get list of boards supported by the waf build
|
2015-12-07 14:33:25 -04:00
|
|
|
for board in $($waf list_boards | head -n1); do waf_supported_boards[$board]=1; done
|
2015-11-27 14:50:45 -04:00
|
|
|
|
2016-05-24 23:32:04 -03:00
|
|
|
function get_time {
|
|
|
|
date -u "+%s"
|
|
|
|
}
|
|
|
|
|
2016-01-18 15:37:53 -04:00
|
|
|
echo "Targets: $CI_BUILD_TARGET"
|
|
|
|
for t in $CI_BUILD_TARGET; do
|
2018-01-22 21:33:52 -04:00
|
|
|
# special case for SITL testing in CI
|
|
|
|
if [ $t == "sitltest-copter" ]; then
|
|
|
|
echo "Installing pymavlink"
|
|
|
|
git submodule init
|
|
|
|
git submodule update
|
|
|
|
(cd modules/mavlink/pymavlink && python setup.py build install --user)
|
|
|
|
unset BUILDROOT
|
|
|
|
echo "Running SITL QuadCopter test"
|
|
|
|
Tools/autotest/autotest.py build.ArduCopter fly.ArduCopter
|
|
|
|
ccache -s && ccache -z
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if [ $t == "sitltest-quadplane" ]; then
|
|
|
|
echo "Installing pymavlink"
|
|
|
|
git submodule init
|
|
|
|
git submodule update
|
|
|
|
(cd modules/mavlink/pymavlink && python setup.py build install --user)
|
|
|
|
unset BUILDROOT
|
|
|
|
echo "Running SITL QuadPlane test"
|
|
|
|
Tools/autotest/autotest.py build.ArduPlane fly.QuadPlane
|
|
|
|
ccache -s && ccache -z
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if [ $t == "sitltest-rover" ]; then
|
|
|
|
echo "Installing pymavlink"
|
|
|
|
git submodule init
|
|
|
|
git submodule update
|
|
|
|
(cd modules/mavlink/pymavlink && python setup.py build install --user)
|
|
|
|
unset BUILDROOT
|
|
|
|
echo "Running SITL Rover test"
|
|
|
|
Tools/autotest/autotest.py build.APMrover2 drive.APMrover2
|
|
|
|
ccache -s && ccache -z
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2017-08-24 21:11:21 -03:00
|
|
|
# only do make-based builds for GCC, when target is PX4-v3 or build is launched by a scheduled job and target is a PX4 board or SITL
|
|
|
|
if [[ "$cxx_compiler" != "clang++" && ($t == "px4-v3" || (-n ${CI_CRON_JOB+1} && ($t == "px4"* || $t == "sitl"))) ]]; then
|
2016-03-08 20:52:33 -04:00
|
|
|
echo "Starting make based build for target ${t}..."
|
2016-10-29 04:42:22 -03:00
|
|
|
for v in "ArduPlane" "ArduCopter" "APMrover2" "ArduSub" "AntennaTracker"; do
|
2016-03-08 20:52:33 -04:00
|
|
|
echo "Building $v for ${t}..."
|
|
|
|
|
|
|
|
pushd $v
|
|
|
|
make clean
|
2016-05-11 17:09:43 -03:00
|
|
|
if [[ $t == "px4"* ]]; then
|
|
|
|
make px4-cleandep
|
2016-03-08 20:52:33 -04:00
|
|
|
fi
|
|
|
|
|
2016-05-24 23:32:04 -03:00
|
|
|
start_time=$(get_time)
|
2017-08-24 21:55:01 -03:00
|
|
|
CCACHE_DISABLE="true" make $t -j$(nproc)
|
2016-05-24 23:32:04 -03:00
|
|
|
diff_time=$(($(get_time)-$start_time))
|
|
|
|
echo -e "\033[32m'make' finished successfully (${diff_time}s)\033[0m"
|
2016-03-08 20:52:33 -04:00
|
|
|
popd
|
|
|
|
done
|
|
|
|
fi
|
2015-11-27 14:50:45 -04:00
|
|
|
|
2016-05-17 11:39:24 -03:00
|
|
|
if [[ -n ${waf_supported_boards[$t]} && -z ${CI_CRON_JOB+1} ]]; then
|
2015-11-27 14:50:45 -04:00
|
|
|
echo "Starting waf build for board ${t}..."
|
2016-03-08 20:52:33 -04:00
|
|
|
$waf configure --board $t --enable-benchmarks --check-c-compiler="$c_compiler" --check-cxx-compiler="$cxx_compiler"
|
2015-12-07 14:33:25 -04:00
|
|
|
$waf clean
|
2016-05-17 11:39:24 -03:00
|
|
|
$waf all
|
2016-05-17 02:16:42 -03:00
|
|
|
ccache -s && ccache -z
|
|
|
|
|
2016-01-19 09:02:10 -04:00
|
|
|
if [[ $t == linux ]]; then
|
|
|
|
$waf check
|
|
|
|
fi
|
2015-11-27 14:50:45 -04:00
|
|
|
fi
|
2014-12-31 18:32:25 -04:00
|
|
|
done
|
2016-01-19 16:41:18 -04:00
|
|
|
|
|
|
|
echo build OK
|
|
|
|
exit 0
|