Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/scripts/build_ci.sh
9531 views
1
#!/usr/bin/env bash
2
# useful script to test all the different build types that we support.
3
# This helps when doing large merges
4
# Andrew Tridgell, November 2011
5
6
XOLDPWD=$PWD # profile changes directory :-(
7
8
if [ -z "$GITHUB_ACTIONS" ] || [ "$GITHUB_ACTIONS" != "true" ]; then
9
. ~/.profile
10
fi
11
12
if [ "$CI" = "true" ]; then
13
echo "::group::Build_ci.sh Setup"
14
export PIP_ROOT_USER_ACTION=ignore
15
fi
16
17
cd $XOLDPWD
18
19
set -ex
20
21
# CXX and CC are exported by default by travis
22
c_compiler=${CC:-gcc}
23
cxx_compiler=${CXX:-g++}
24
25
# we want processes to exit in CI. If we don't end up calling
26
# alarm_handler and not getting the binaries in the failure archive on
27
# github.
28
export SITL_PANIC_EXIT=1
29
30
export BUILDROOT=/tmp/ci.build
31
rm -rf $BUILDROOT
32
export GIT_VERSION="abcdef"
33
export GIT_VERSION_EXTENDED="0123456789abcdef"
34
export GIT_VERSION_INT="15"
35
export CHIBIOS_GIT_VERSION="12345667"
36
export CCACHE_SLOPPINESS="include_file_ctime,include_file_mtime"
37
autotest_args=""
38
39
# If CI_BUILD_TARGET is not set, build 4 different ones
40
if [ -z "$CI_BUILD_TARGET" ]; then
41
CI_BUILD_TARGET="sitl linux fmuv3 omnibusf4pro-one"
42
fi
43
44
waf=modules/waf/waf-light
45
46
echo "Targets: $CI_BUILD_TARGET"
47
echo "Compiler: $c_compiler"
48
49
pymavlink_installed=0
50
mavproxy_installed=0
51
52
if [ "$CI" = "true" ]; then
53
echo "::endgroup::"
54
fi
55
56
function install_pymavlink() {
57
if [ "$CI" = "true" ]; then
58
echo "::group::pymavlink install"
59
fi
60
if [ $pymavlink_installed -eq 0 ]; then
61
echo "Installing pymavlink"
62
git submodule update --init --recursive --depth 1
63
(cd modules/mavlink/pymavlink && python3 -m pip install --progress-bar off --cache-dir /tmp/pip-cache --user .)
64
pymavlink_installed=1
65
fi
66
if [ "$CI" = "true" ]; then
67
echo "::endgroup::"
68
fi
69
}
70
71
function install_mavproxy() {
72
if [ "$CI" = "true" ]; then
73
echo "::group::mavproxy install"
74
fi
75
if [ $mavproxy_installed -eq 0 ]; then
76
echo "Installing MAVProxy"
77
pushd /tmp
78
git clone https://github.com/ardupilot/MAVProxy --depth 1
79
pushd MAVProxy
80
python3 -m pip install --progress-bar off --cache-dir /tmp/pip-cache --user --force .
81
popd
82
popd
83
mavproxy_installed=1
84
# now uninstall the version of pymavlink pulled in by MAVProxy deps:
85
python3 -m pip uninstall -y pymavlink --cache-dir /tmp/pip-cache
86
fi
87
if [ "$CI" = "true" ]; then
88
echo "::endgroup::"
89
fi
90
}
91
92
function run_autotest() {
93
NAME="$1"
94
BVEHICLE="$2"
95
RVEHICLE="$3"
96
if [ "$CI" = "true" ]; then
97
echo "::group::cpuinfo"
98
fi
99
# report on what cpu's we have for later log review if needed
100
cat /proc/cpuinfo
101
if [ "$CI" = "true" ]; then
102
echo "::endgroup::"
103
fi
104
105
install_mavproxy
106
install_pymavlink
107
unset BUILDROOT
108
echo "Running SITL $NAME test"
109
110
w=""
111
if [ $c_compiler == "clang" ]; then
112
w="$w --check-c-compiler=clang --check-cxx-compiler=clang++"
113
fi
114
if [ "$NAME" == "Rover" ]; then
115
w="$w --enable-math-check-indexes"
116
fi
117
if [ "x$CI_BUILD_DEBUG" != "x" ]; then
118
w="$w --debug"
119
fi
120
if [ "$NAME" == "Plane" ]; then
121
w="$w --num-aux-imus=2"
122
fi
123
if [ "$NAME" == "Examples" ]; then
124
w="$w --speedup=5 --timeout=14400 --debug --no-clean"
125
fi
126
Tools/autotest/autotest.py --show-test-timings --junit --waf-configure-args="$w" "$BVEHICLE" "$RVEHICLE"
127
ccache -s && ccache -z
128
}
129
130
for t in $CI_BUILD_TARGET; do
131
# special case for SITL testing in CI
132
if [ "$t" == "sitltest-heli" ]; then
133
run_autotest "Heli" "build.Helicopter" "test.Helicopter"
134
continue
135
fi
136
#github actions ci
137
if [ "$t" == "sitltest-copter-tests1a" ]; then
138
run_autotest "Copter" "build.Copter" "test.CopterTests1a"
139
continue
140
fi
141
if [ "$t" == "sitltest-copter-tests1b" ]; then
142
run_autotest "Copter" "build.Copter" "test.CopterTests1b"
143
continue
144
fi
145
if [ "$t" == "sitltest-copter-tests1c" ]; then
146
run_autotest "Copter" "build.Copter" "test.CopterTests1c"
147
continue
148
fi
149
if [ "$t" == "sitltest-copter-tests1d" ]; then
150
run_autotest "Copter" "build.Copter" "test.CopterTests1d"
151
continue
152
fi
153
if [ "$t" == "sitltest-copter-tests1e" ]; then
154
run_autotest "Copter" "build.Copter" "test.CopterTests1e"
155
continue
156
fi
157
if [ "$t" == "sitltest-copter-tests2a" ]; then
158
run_autotest "Copter" "build.Copter" "test.CopterTests2a"
159
continue
160
fi
161
if [ "$t" == "sitltest-copter-tests2b" ]; then
162
run_autotest "Copter" "build.Copter" "test.CopterTests2b"
163
continue
164
fi
165
if [ "$t" == "sitltest-can" ]; then
166
echo "Building SITL Periph GPS"
167
$waf configure --board sitl
168
$waf copter
169
run_autotest "Copter" "build.SITLPeriphUniversal" "test.CAN"
170
continue
171
fi
172
if [ "$t" == "sitltest-plane-tests1a" ]; then
173
run_autotest "Plane" "build.Plane" "test.PlaneTests1a"
174
continue
175
fi
176
if [ "$t" == "sitltest-plane-tests1b" ]; then
177
run_autotest "Plane" "build.Plane" "test.PlaneTests1b"
178
continue
179
fi
180
if [ "$t" == "sitltest-plane-tests1c" ]; then
181
run_autotest "Plane" "build.Plane" "test.PlaneTests1c"
182
continue
183
fi
184
if [ "$t" == "sitltest-quadplane" ]; then
185
run_autotest "QuadPlane" "build.Plane" "test.QuadPlane"
186
continue
187
fi
188
if [ "$t" == "sitltest-rover" ]; then
189
sudo apt-get update || /bin/true
190
sudo apt-get install -y ppp || /bin/true
191
pppd --help # fail with `command not found` if ppp install failed
192
run_autotest "Rover" "build.Rover" "test.Rover"
193
continue
194
fi
195
if [ "$t" == "sitltest-sailboat" ]; then
196
run_autotest "Rover" "build.Rover" "test.Sailboat"
197
continue
198
fi
199
if [ "$t" == "sitltest-tracker" ]; then
200
run_autotest "Tracker" "build.Tracker" "test.Tracker"
201
continue
202
fi
203
if [ "$t" == "sitltest-balancebot" ]; then
204
run_autotest "BalanceBot" "build.Rover" "test.BalanceBot"
205
continue
206
fi
207
if [ "$t" == "sitltest-sub" ]; then
208
run_autotest "Sub" "build.Sub" "test.Sub"
209
continue
210
fi
211
if [ "$t" == "sitltest-blimp" ]; then
212
run_autotest "Blimp" "build.Blimp" "test.Blimp"
213
continue
214
fi
215
216
if [ "$t" == "unit-tests" ]; then
217
run_autotest "Unit Tests" "build.unit_tests" "run.unit_tests"
218
continue
219
fi
220
221
if [ "$t" == "examples" ]; then
222
./waf configure --board=sitl --debug
223
./waf examples
224
run_autotest "Examples" "--no-clean" "run.examples"
225
continue
226
fi
227
228
if [ "$t" == "revo-bootloader" ]; then
229
echo "Building revo bootloader"
230
if [ -f ~/alternate_build/revo-mini/bin/AP_Bootloader.bin ]; then
231
rm -r ~/alternate_build
232
fi
233
$waf configure --board revo-mini --bootloader --out ~/alternate_build
234
$waf clean
235
$waf bootloader
236
# check if bootloader got built under alternate_build
237
if [ ! -f ~/alternate_build/revo-mini/bin/AP_Bootloader.bin ]; then
238
echo "alternate build output directory Test failed"
239
exit 1
240
fi
241
continue
242
fi
243
244
if [ "$t" == "periph-build" ]; then
245
echo "Building f103 bootloader"
246
$waf configure --board f103-GPS --bootloader
247
$waf clean
248
$waf bootloader
249
echo "Building f103 peripheral fw"
250
$waf configure --board f103-GPS
251
$waf clean
252
$waf AP_Periph
253
echo "Building f303 bootloader"
254
$waf configure --board f303-Universal --bootloader
255
$waf clean
256
$waf bootloader
257
echo "Building f303 peripheral fw"
258
$waf configure --board f303-Universal
259
$waf clean
260
$waf AP_Periph
261
echo "Building CubeOrange-periph peripheral fw"
262
$waf configure --board CubeOrange-periph
263
$waf clean
264
$waf AP_Periph
265
echo "Building G4-ESC peripheral fw"
266
$waf configure --board G4-ESC
267
$waf clean
268
$waf AP_Periph
269
echo "Building Nucleo-L496 peripheral fw"
270
$waf configure --board Nucleo-L496
271
$waf clean
272
$waf AP_Periph
273
echo "Building Nucleo-L496 peripheral fw"
274
$waf configure --board Nucleo-L476
275
$waf clean
276
$waf AP_Periph
277
echo "Building Sierra-L431 peripheral fw"
278
$waf configure --board Sierra-L431
279
$waf clean
280
$waf AP_Periph
281
echo "Building FreeflyRTK peripheral fw"
282
$waf configure --board FreeflyRTK
283
$waf clean
284
$waf AP_Periph
285
echo "Building CubeNode-ETH peripheral fw"
286
$waf configure --board CubeNode-ETH
287
$waf clean
288
$waf AP_Periph
289
continue
290
fi
291
292
if [ "$t" == "CubeOrange-bootloader" ]; then
293
echo "Building CubeOrange bootloader"
294
$waf configure --board CubeOrange --bootloader
295
$waf clean
296
$waf bootloader
297
continue
298
fi
299
300
if [ "$t" == "CubeRedPrimary-bootloader" ]; then
301
echo "Building CubeRedPrimary bootloader"
302
$waf configure --board CubeRedPrimary --bootloader
303
$waf clean
304
$waf bootloader
305
continue
306
fi
307
308
if [ "$t" == "fmuv3-bootloader" ]; then
309
echo "Building fmuv3 bootloader"
310
$waf configure --board fmuv3 --bootloader
311
$waf clean
312
$waf bootloader
313
continue
314
fi
315
316
if [ "$t" == "stm32f7" ]; then
317
echo "Building mRoX21-777/"
318
$waf configure --Werror --board mRoX21-777
319
$waf clean
320
$waf plane
321
322
# test bi-directional dshot build
323
echo "Building KakuteF7Mini"
324
$waf configure --Werror --board KakuteF7Mini
325
$waf clean
326
$waf copter
327
328
# test bi-directional dshot build and smallest flash
329
echo "Building KakuteF7"
330
$waf configure --Werror --board KakuteF7
331
$waf clean
332
$waf copter
333
continue
334
fi
335
336
if [ "$t" == "stm32h7" ]; then
337
echo "Building Durandal"
338
$waf configure --board Durandal
339
$waf clean
340
$waf copter
341
echo "Building CPUInfo"
342
$waf --target=tool/CPUInfo
343
344
# test external flash build
345
echo "Building SPRacingH7"
346
$waf configure --Werror --board SPRacingH7
347
$waf clean
348
$waf copter
349
continue
350
fi
351
352
if [ "$t" == "stm32h7-debug" ]; then
353
echo "Building Durandal"
354
$waf configure --board Durandal --debug
355
$waf clean
356
$waf copter
357
continue
358
fi
359
360
if [ "$t" == "CubeOrange-ODID" ]; then
361
echo "Building CubeOrange-ODID"
362
$waf configure --board CubeOrange-ODID
363
$waf clean
364
$waf copter
365
$waf plane
366
continue
367
fi
368
369
if [ "$t" == "CubeOrange-PPP" ]; then
370
echo "Building CubeOrange-PPP"
371
$waf configure --board CubeOrange --enable-PPP
372
$waf clean
373
$waf copter
374
continue
375
fi
376
377
if [ "$t" == "CubeOrange-EKF2" ]; then
378
echo "Building CubeOrange with EKF2 enabled"
379
$waf configure --board CubeOrange --enable-EKF2
380
$waf clean
381
$waf copter
382
continue
383
fi
384
385
if [ "$t" == "SOHW" ]; then
386
echo "Building CubeOrange-SOHW"
387
Tools/scripts/sitl-on-hardware/sitl-on-hw.py --board CubeOrange --vehicle copter --simclass MultiCopter
388
echo "Building 6X-SOHW"
389
Tools/scripts/sitl-on-hardware/sitl-on-hw.py --board Pixhawk6X --vehicle plane --simclass Plane --frame plane-3d
390
continue
391
fi
392
393
if [ "$t" == "Pixhawk6X-PPPGW" ]; then
394
echo "Building Pixhawk6X-PPPGW"
395
$waf configure --board Pixhawk6X-PPPGW
396
$waf clean
397
$waf AP_Periph
398
$waf configure --board Pixhawk6X-PPPGW --bootloader
399
$waf clean
400
$waf bootloader
401
continue
402
fi
403
404
if [ "$t" == "new-check" ]; then
405
echo "Building Pixhawk6X with new check"
406
$waf configure --board Pixhawk6X --enable-new-checking
407
$waf clean
408
$waf
409
echo "Building Pixhawk6X-PPPGW with new check"
410
$waf configure --board Pixhawk6X-PPPGW --enable-new-checking
411
$waf clean
412
$waf AP_Periph
413
continue
414
fi
415
416
if [ "$t" == "dds-stm32h7" ]; then
417
echo "Building with DDS support on a STM32H7"
418
$waf configure --board Durandal --enable-DDS
419
$waf clean
420
$waf copter
421
$waf plane
422
continue
423
fi
424
425
if [ "$t" == "dds-sitl" ]; then
426
echo "Building with DDS support on SITL"
427
$waf configure --board sitl --enable-DDS
428
$waf clean
429
$waf copter
430
$waf plane
431
$waf tests
432
continue
433
fi
434
435
if [ "$t" == "fmuv2-plane" ]; then
436
echo "Building fmuv2 plane"
437
$waf configure --board fmuv2
438
$waf clean
439
$waf plane
440
continue
441
fi
442
443
if [ "$t" == "iofirmware" ]; then
444
echo "Building iofirmware"
445
Tools/scripts/build_iofirmware.py
446
# now clean up the stuff that's copied into the source tree:
447
git checkout Tools/IO_Firmware/
448
continue
449
fi
450
451
if [ "$t" == "navigator" ]; then
452
echo "Building navigator"
453
$waf configure --board navigator --toolchain=arm-linux-musleabihf
454
$waf sub --static
455
./Tools/scripts/firmware_version_decoder.py -f build/navigator/bin/ardusub --expected-hash $GIT_VERSION
456
continue
457
fi
458
459
if [ "$t" == "navigator64" ]; then
460
echo "Building navigator64"
461
$waf configure --board navigator64 --toolchain=aarch64-linux-gnu
462
$waf sub
463
./Tools/scripts/firmware_version_decoder.py -f build/navigator64/bin/ardusub --expected-hash $GIT_VERSION
464
continue
465
fi
466
467
if [ "$t" == "replay" ]; then
468
echo "Building replay"
469
$waf configure --board sitl --debug --disable-scripting
470
471
$waf replay
472
echo "Building AP_DAL standalone test"
473
$waf configure --board sitl --debug --disable-scripting --no-gcs
474
475
$waf --target tool/AP_DAL_Standalone
476
$waf clean
477
continue
478
fi
479
480
if [ "$t" == "validate_board_list" ]; then
481
echo "Validating board list"
482
./Tools/autotest/validate_board_list.py
483
continue
484
fi
485
486
if [ "$t" == "check_autotest_options" ]; then
487
echo "Checking autotest options"
488
install_mavproxy
489
install_pymavlink
490
./Tools/autotest/autotest.py --help
491
./Tools/autotest/autotest.py --list
492
./Tools/autotest/autotest.py --list-subtests
493
continue
494
fi
495
496
if [ "$t" == "signing" ]; then
497
echo "Building signed firmwares"
498
sudo apt-get update
499
sudo apt-get install -y python3-dev
500
python3 -m pip install pymonocypher==3.1.3.2 --progress-bar off --cache-dir /tmp/pip-cache
501
./Tools/scripts/signing/generate_keys.py testkey
502
$waf configure --board CubeOrange-ODID --signed-fw --private-key testkey_private_key.dat
503
$waf copter
504
$waf configure --board MatekL431-DShot --signed-fw --private-key testkey_private_key.dat
505
$waf AP_Periph
506
./Tools/scripts/build_bootloaders.py --signing-key testkey_public_key.dat CubeOrange-ODID
507
./Tools/scripts/build_bootloaders.py --signing-key testkey_public_key.dat MatekL431-DShot
508
continue
509
fi
510
511
if [ "$t" == "python-cleanliness" ]; then
512
echo "Checking Python code cleanliness"
513
./Tools/scripts/run_flake8.py
514
continue
515
fi
516
517
if [ "$t" == "astyle-cleanliness" ]; then
518
echo "Checking AStyle code cleanliness"
519
520
./Tools/scripts/run_astyle.py --dry-run
521
if [ $? -ne 0 ]; then
522
echo The code failed astyle cleanliness checks. Please run ./Tools/scripts/run_astyle.py
523
fi
524
continue
525
fi
526
527
if [ "$t" == "param-file-validation" ]; then
528
echo "Testing param check script"
529
./Tools/scripts/param_check_unittests.py
530
echo "Validating parameter files"
531
./Tools/scripts/param_check_all.py
532
continue
533
fi
534
535
if [ "$t" == "configure-all" ]; then
536
echo "Checking configure of all boards"
537
./Tools/scripts/configure_all.py
538
continue
539
fi
540
541
if [ "$t" == "build-options-defaults-test" ]; then
542
install_pymavlink
543
echo "Checking default options in build_options.py work"
544
time ./Tools/autotest/test_build_options.py \
545
--no-disable-all \
546
--no-disable-none \
547
--no-disable-in-turn \
548
--no-enable-in-turn \
549
--board=CubeOrange \
550
--build-targets=copter \
551
--build-targets=plane
552
echo "Checking all/none options in build_options.py work"
553
time ./Tools/autotest/test_build_options.py \
554
--no-disable-in-turn \
555
--no-enable-in-turn \
556
--build-targets=copter \
557
--build-targets=plane
558
echo "Checking building with logging disabled works"
559
echo "define HAL_LOGGING_ENABLED 0" >/tmp/extra.hwdef
560
time ./waf configure \
561
--board=CubeOrange \
562
--extra-hwdef=/tmp/extra.hwdef
563
time ./waf plane
564
time ./waf copter
565
continue
566
fi
567
568
if [ "$t" == "param_parse" ]; then
569
for v in Rover AntennaTracker ArduCopter ArduPlane ArduSub Blimp AP_Periph; do
570
python3 Tools/autotest/param_metadata/param_parse.py --vehicle $v
571
done
572
continue
573
fi
574
575
if [ "$t" == "logger_metadata" ]; then
576
for v in Rover Tracker Copter Plane Sub Blimp; do
577
python3 Tools/autotest/logger_metadata/parse.py --vehicle $v
578
done
579
continue
580
fi
581
582
if [[ -z ${CI_CRON_JOB+1} ]]; then
583
echo "Starting waf build for board ${t}..."
584
$waf configure --board "$t" \
585
--enable-benchmarks \
586
--enable-header-checks \
587
--check-c-compiler="$c_compiler" \
588
--check-cxx-compiler="$cxx_compiler"
589
$waf clean
590
$waf all
591
ccache -s && ccache -z
592
593
if [[ $t == "linux" ]]; then
594
$waf check
595
fi
596
continue
597
fi
598
done
599
600
echo build OK
601
exit 0
602
603