CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

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