Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/scripts/build_ci.sh
Views: 1798
#!/usr/bin/env bash1# useful script to test all the different build types that we support.2# This helps when doing large merges3# Andrew Tridgell, November 201145XOLDPWD=$PWD # profile changes directory :-(67if [ -z "$GITHUB_ACTIONS" ] || [ "$GITHUB_ACTIONS" != "true" ]; then8. ~/.profile9fi1011if [ "$CI" = "true" ]; then12export PIP_ROOT_USER_ACTION=ignore13fi1415cd $XOLDPWD1617set -ex1819# CXX and CC are exported by default by travis20c_compiler=${CC:-gcc}21cxx_compiler=${CXX:-g++}2223export BUILDROOT=/tmp/ci.build24rm -rf $BUILDROOT25export GIT_VERSION="abcdef"26export GIT_VERSION_INT="15"27export CHIBIOS_GIT_VERSION="12345667"28export CCACHE_SLOPPINESS="include_file_ctime,include_file_mtime"29autotest_args=""3031# If CI_BUILD_TARGET is not set, build 4 different ones32if [ -z "$CI_BUILD_TARGET" ]; then33CI_BUILD_TARGET="sitl linux fmuv3 omnibusf4pro-one"34fi3536waf=modules/waf/waf-light3738echo "Targets: $CI_BUILD_TARGET"39echo "Compiler: $c_compiler"4041pymavlink_installed=042mavproxy_installed=04344function install_pymavlink() {45if [ $pymavlink_installed -eq 0 ]; then46echo "Installing pymavlink"47git submodule update --init --recursive --depth 148(cd modules/mavlink/pymavlink && python3 -m pip install --progress-bar off --cache-dir /tmp/pip-cache --user .)49pymavlink_installed=150fi51}5253function install_mavproxy() {54if [ $mavproxy_installed -eq 0 ]; then55echo "Installing MAVProxy"56pushd /tmp57git clone https://github.com/ardupilot/MAVProxy --depth 158pushd MAVProxy59python3 -m pip install --progress-bar off --cache-dir /tmp/pip-cache --user --force .60popd61popd62mavproxy_installed=163# now uninstall the version of pymavlink pulled in by MAVProxy deps:64python3 -m pip uninstall -y pymavlink --cache-dir /tmp/pip-cache65fi66}6768function run_autotest() {69NAME="$1"70BVEHICLE="$2"71RVEHICLE="$3"7273# report on what cpu's we have for later log review if needed74cat /proc/cpuinfo7576install_mavproxy77install_pymavlink78unset BUILDROOT79echo "Running SITL $NAME test"8081w=""82if [ $c_compiler == "clang" ]; then83w="$w --check-c-compiler=clang --check-cxx-compiler=clang++"84fi85if [ "$NAME" == "Rover" ]; then86w="$w --enable-math-check-indexes"87fi88if [ "x$CI_BUILD_DEBUG" != "x" ]; then89w="$w --debug"90fi91if [ "$NAME" == "Plane" ]; then92w="$w --num-aux-imus=2"93fi94if [ "$NAME" == "Examples" ]; then95w="$w --speedup=5 --timeout=14400 --debug --no-clean"96fi97Tools/autotest/autotest.py --show-test-timings --junit --waf-configure-args="$w" "$BVEHICLE" "$RVEHICLE"98ccache -s && ccache -z99}100101for t in $CI_BUILD_TARGET; do102# special case for SITL testing in CI103if [ "$t" == "sitltest-heli" ]; then104run_autotest "Heli" "build.Helicopter" "test.Helicopter"105continue106fi107#github actions ci108if [ "$t" == "sitltest-copter-tests1a" ]; then109run_autotest "Copter" "build.Copter" "test.CopterTests1a"110continue111fi112if [ "$t" == "sitltest-copter-tests1b" ]; then113run_autotest "Copter" "build.Copter" "test.CopterTests1b"114continue115fi116if [ "$t" == "sitltest-copter-tests1c" ]; then117run_autotest "Copter" "build.Copter" "test.CopterTests1c"118continue119fi120if [ "$t" == "sitltest-copter-tests1d" ]; then121run_autotest "Copter" "build.Copter" "test.CopterTests1d"122continue123fi124if [ "$t" == "sitltest-copter-tests1e" ]; then125run_autotest "Copter" "build.Copter" "test.CopterTests1e"126continue127fi128if [ "$t" == "sitltest-copter-tests2a" ]; then129run_autotest "Copter" "build.Copter" "test.CopterTests2a"130continue131fi132if [ "$t" == "sitltest-copter-tests2b" ]; then133run_autotest "Copter" "build.Copter" "test.CopterTests2b"134continue135fi136if [ "$t" == "sitltest-can" ]; then137echo "Building SITL Periph GPS"138$waf configure --board sitl139$waf copter140run_autotest "Copter" "build.SITLPeriphUniversal" "test.CAN"141continue142fi143if [ "$t" == "sitltest-plane-tests1a" ]; then144run_autotest "Plane" "build.Plane" "test.PlaneTests1a"145continue146fi147if [ "$t" == "sitltest-plane-tests1b" ]; then148run_autotest "Plane" "build.Plane" "test.PlaneTests1b"149continue150fi151if [ "$t" == "sitltest-quadplane" ]; then152run_autotest "QuadPlane" "build.Plane" "test.QuadPlane"153continue154fi155if [ "$t" == "sitltest-rover" ]; then156sudo apt-get update || /bin/true157sudo apt-get install -y ppp || /bin/true158run_autotest "Rover" "build.Rover" "test.Rover"159continue160fi161if [ "$t" == "sitltest-sailboat" ]; then162run_autotest "Rover" "build.Rover" "test.Sailboat"163continue164fi165if [ "$t" == "sitltest-tracker" ]; then166run_autotest "Tracker" "build.Tracker" "test.Tracker"167continue168fi169if [ "$t" == "sitltest-balancebot" ]; then170run_autotest "BalanceBot" "build.Rover" "test.BalanceBot"171continue172fi173if [ "$t" == "sitltest-sub" ]; then174run_autotest "Sub" "build.Sub" "test.Sub"175continue176fi177if [ "$t" == "sitltest-blimp" ]; then178run_autotest "Blimp" "build.Blimp" "test.Blimp"179continue180fi181182if [ "$t" == "unit-tests" ]; then183run_autotest "Unit Tests" "build.unit_tests" "run.unit_tests"184continue185fi186187if [ "$t" == "examples" ]; then188./waf configure --board=sitl --debug189./waf examples190run_autotest "Examples" "--no-clean" "run.examples"191continue192fi193194if [ "$t" == "revo-bootloader" ]; then195echo "Building revo bootloader"196if [ -f ~/alternate_build/revo-mini/bin/AP_Bootloader.bin ]; then197rm -r ~/alternate_build198fi199$waf configure --board revo-mini --bootloader --out ~/alternate_build200$waf clean201$waf bootloader202# check if bootloader got built under alternate_build203if [ ! -f ~/alternate_build/revo-mini/bin/AP_Bootloader.bin ]; then204echo "alternate build output directory Test failed"205exit 1206fi207continue208fi209210if [ "$t" == "periph-build" ]; then211echo "Building f103 bootloader"212$waf configure --board f103-GPS --bootloader213$waf clean214$waf bootloader215echo "Building f103 peripheral fw"216$waf configure --board f103-GPS217$waf clean218$waf AP_Periph219echo "Building f303 bootloader"220$waf configure --board f303-Universal --bootloader221$waf clean222$waf bootloader223echo "Building f303 peripheral fw"224$waf configure --board f303-Universal225$waf clean226$waf AP_Periph227echo "Building CubeOrange-periph peripheral fw"228$waf configure --board CubeOrange-periph229$waf clean230$waf AP_Periph231echo "Building G4-ESC peripheral fw"232$waf configure --board G4-ESC233$waf clean234$waf AP_Periph235echo "Building Nucleo-L496 peripheral fw"236$waf configure --board Nucleo-L496237$waf clean238$waf AP_Periph239echo "Building Nucleo-L496 peripheral fw"240$waf configure --board Nucleo-L476241$waf clean242$waf AP_Periph243echo "Building Sierra-L431 peripheral fw"244$waf configure --board Sierra-L431245$waf clean246$waf AP_Periph247echo "Building FreeflyRTK peripheral fw"248$waf configure --board FreeflyRTK249$waf clean250$waf AP_Periph251echo "Building CubeNode-ETH peripheral fw"252$waf configure --board CubeNode-ETH253$waf clean254$waf AP_Periph255continue256fi257258if [ "$t" == "CubeOrange-bootloader" ]; then259echo "Building CubeOrange bootloader"260$waf configure --board CubeOrange --bootloader261$waf clean262$waf bootloader263continue264fi265266if [ "$t" == "CubeRedPrimary-bootloader" ]; then267echo "Building CubeRedPrimary bootloader"268$waf configure --board CubeRedPrimary --bootloader269$waf clean270$waf bootloader271continue272fi273274if [ "$t" == "fmuv3-bootloader" ]; then275echo "Building fmuv3 bootloader"276$waf configure --board fmuv3 --bootloader277$waf clean278$waf bootloader279continue280fi281282if [ "$t" == "stm32f7" ]; then283echo "Building mRoX21-777/"284$waf configure --Werror --board mRoX21-777285$waf clean286$waf plane287288# test bi-directional dshot build289echo "Building KakuteF7Mini"290$waf configure --Werror --board KakuteF7Mini291$waf clean292$waf copter293294# test bi-directional dshot build and smallest flash295echo "Building KakuteF7"296$waf configure --Werror --board KakuteF7297$waf clean298$waf copter299continue300fi301302if [ "$t" == "stm32h7" ]; then303echo "Building Durandal"304$waf configure --board Durandal305$waf clean306$waf copter307echo "Building CPUInfo"308$waf --target=tool/CPUInfo309310# test external flash build311echo "Building SPRacingH7"312$waf configure --Werror --board SPRacingH7313$waf clean314$waf copter315continue316fi317318if [ "$t" == "stm32h7-debug" ]; then319echo "Building Durandal"320$waf configure --board Durandal --debug321$waf clean322$waf copter323continue324fi325326if [ "$t" == "CubeOrange-ODID" ]; then327echo "Building CubeOrange-ODID"328$waf configure --board CubeOrange-ODID329$waf clean330$waf copter331$waf plane332continue333fi334335if [ "$t" == "CubeOrange-PPP" ]; then336echo "Building CubeOrange-PPP"337$waf configure --board CubeOrange --enable-PPP338$waf clean339$waf copter340continue341fi342343if [ "$t" == "CubeRed-EKF2" ]; then344echo "Building CubeRed with EKF2 enabled"345$waf configure --board CubeRedPrimary --enable-EKF2346$waf clean347$waf copter348continue349fi350351if [ "$t" == "SOHW" ]; then352echo "Building CubeOrange-SOHW"353Tools/scripts/sitl-on-hardware/sitl-on-hw.py --board CubeOrange --vehicle copter --simclass MultiCopter354echo "Building 6X-SOHW"355Tools/scripts/sitl-on-hardware/sitl-on-hw.py --board Pixhawk6X --vehicle plane --simclass Plane --frame plane-3d356continue357fi358359if [ "$t" == "Pixhawk6X-PPPGW" ]; then360echo "Building Pixhawk6X-PPPGW"361$waf configure --board Pixhawk6X-PPPGW362$waf clean363$waf AP_Periph364$waf configure --board Pixhawk6X-PPPGW --bootloader365$waf clean366$waf bootloader367continue368fi369370if [ "$t" == "new-check" ]; then371echo "Building Pixhawk6X with new check"372$waf configure --board Pixhawk6X --enable-new-checking373$waf clean374$waf375echo "Building Pixhawk6X-PPPGW with new check"376$waf configure --board Pixhawk6X-PPPGW --enable-new-checking377$waf clean378$waf AP_Periph379continue380fi381382if [ "$t" == "dds-stm32h7" ]; then383echo "Building with DDS support on a STM32H7"384$waf configure --board Durandal --enable-dds385$waf clean386$waf copter387$waf plane388continue389fi390391if [ "$t" == "dds-sitl" ]; then392echo "Building with DDS support on SITL"393$waf configure --board sitl --enable-dds394$waf clean395$waf copter396$waf plane397$waf tests398continue399fi400401if [ "$t" == "fmuv2-plane" ]; then402echo "Building fmuv2 plane"403$waf configure --board fmuv2404$waf clean405$waf plane406continue407fi408409if [ "$t" == "iofirmware" ]; then410echo "Building iofirmware"411Tools/scripts/build_iofirmware.py412# now clean up the stuff that's copied into the source tree:413git checkout Tools/IO_Firmware/414continue415fi416417if [ "$t" == "navigator" ]; then418echo "Building navigator"419$waf configure --board navigator --toolchain=arm-linux-musleabihf420$waf sub --static421./Tools/scripts/firmware_version_decoder.py -f build/navigator/bin/ardusub --expected-hash $GIT_VERSION422continue423fi424425if [ "$t" == "navigator64" ]; then426echo "Building navigator64"427$waf configure --board navigator64 --toolchain=aarch64-linux-gnu428$waf sub429./Tools/scripts/firmware_version_decoder.py -f build/navigator64/bin/ardusub --expected-hash $GIT_VERSION430continue431fi432433if [ "$t" == "replay" ]; then434echo "Building replay"435$waf configure --board sitl --debug --disable-scripting436437$waf replay438echo "Building AP_DAL standalone test"439$waf configure --board sitl --debug --disable-scripting --no-gcs440441$waf --target tool/AP_DAL_Standalone442$waf clean443continue444fi445446if [ "$t" == "validate_board_list" ]; then447echo "Validating board list"448./Tools/autotest/validate_board_list.py449continue450fi451452if [ "$t" == "check_autotest_options" ]; then453echo "Checking autotest options"454install_mavproxy455install_pymavlink456./Tools/autotest/autotest.py --help457./Tools/autotest/autotest.py --list458./Tools/autotest/autotest.py --list-subtests459continue460fi461462if [ "$t" == "signing" ]; then463echo "Building signed firmwares"464sudo apt-get update465sudo apt-get install -y python3-dev466python3 -m pip install pymonocypher==3.1.3.2 --progress-bar off --cache-dir /tmp/pip-cache467./Tools/scripts/signing/generate_keys.py testkey468$waf configure --board CubeOrange-ODID --signed-fw --private-key testkey_private_key.dat469$waf copter470$waf configure --board MatekL431-DShot --signed-fw --private-key testkey_private_key.dat471$waf AP_Periph472./Tools/scripts/build_bootloaders.py --signing-key testkey_public_key.dat CubeOrange-ODID473./Tools/scripts/build_bootloaders.py --signing-key testkey_public_key.dat MatekL431-DShot474continue475fi476477if [ "$t" == "python-cleanliness" ]; then478echo "Checking Python code cleanliness"479./Tools/scripts/run_flake8.py480continue481fi482483if [ "$t" == "astyle-cleanliness" ]; then484echo "Checking AStyle code cleanliness"485486./Tools/scripts/run_astyle.py --dry-run487if [ $? -ne 0 ]; then488echo The code failed astyle cleanliness checks. Please run ./Tools/scripts/run_astyle.py489fi490continue491fi492493if [ "$t" == "configure-all" ]; then494echo "Checking configure of all boards"495./Tools/scripts/configure_all.py496continue497fi498499if [ "$t" == "build-options-defaults-test" ]; then500install_pymavlink501echo "Checking default options in build_options.py work"502time ./Tools/autotest/test_build_options.py \503--no-disable-all \504--no-disable-none \505--no-disable-in-turn \506--no-enable-in-turn \507--board=CubeOrange \508--build-targets=copter \509--build-targets=plane510echo "Checking all/none options in build_options.py work"511time ./Tools/autotest/test_build_options.py \512--no-disable-in-turn \513--no-enable-in-turn \514--build-targets=copter \515--build-targets=plane516echo "Checking building with logging disabled works"517echo "define HAL_LOGGING_ENABLED 0" >/tmp/extra.hwdef518time ./waf configure \519--board=CubeOrange \520--extra-hwdef=/tmp/extra.hwdef521time ./waf plane522time ./waf copter523continue524fi525526if [ "$t" == "param_parse" ]; then527for v in Rover AntennaTracker ArduCopter ArduPlane ArduSub Blimp AP_Periph; do528python3 Tools/autotest/param_metadata/param_parse.py --vehicle $v529done530continue531fi532533if [ "$t" == "logger_metadata" ]; then534for v in Rover Tracker Copter Plane Sub Blimp; do535python3 Tools/autotest/logger_metadata/parse.py --vehicle $v536done537continue538fi539540if [[ -z ${CI_CRON_JOB+1} ]]; then541echo "Starting waf build for board ${t}..."542$waf configure --board "$t" \543--enable-benchmarks \544--enable-header-checks \545--check-c-compiler="$c_compiler" \546--check-cxx-compiler="$cxx_compiler"547$waf clean548$waf all549ccache -s && ccache -z550551if [[ $t == "linux" ]]; then552$waf check553fi554continue555fi556done557558echo build OK559exit 0560561562