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_peripherals.py
Views: 1798
1
#!/usr/bin/env python
2
3
"""
4
script to test build all of our peripheral firmwares
5
"""
6
7
import os
8
import shutil
9
import subprocess
10
import sys
11
import fnmatch
12
import board_list
13
14
# get command line arguments
15
from argparse import ArgumentParser
16
parser = ArgumentParser(description='build_peripherals')
17
parser.add_argument("pattern", type=str, default='*', help="board wildcard pattern")
18
parser.add_argument("--debug", action='store_true', default=False, help="build with debug symbols")
19
parser.add_argument("--stop", action='store_true', default=False, help="stop on a failed build")
20
parser.add_argument("--configure-only", action='store_true', default=False, help="only run configure")
21
parser.add_argument("--noclean", action='store_true', default=False, help="don't run waf clean")
22
args = parser.parse_args()
23
24
os.environ['PYTHONUNBUFFERED'] = '1'
25
26
failed_boards = set()
27
28
def run_program(cmd_list):
29
print("Running (%s)" % " ".join(cmd_list))
30
retcode = subprocess.call(cmd_list)
31
if retcode != 0:
32
print("Build failed: %s" % ' '.join(cmd_list))
33
return False
34
return True
35
36
def build_board(board):
37
configure_args = "--board %s --no-submodule-update --Werror" % board
38
configure_args = configure_args.split()
39
if args.debug:
40
print("Building with debug symbols")
41
configure_args.append("--debug")
42
if not run_program(["./waf", "configure"] + configure_args):
43
return False
44
if args.configure_only:
45
return True
46
if not args.noclean and not run_program(["./waf", "clean"]):
47
return False
48
if not run_program(["./waf", "AP_Periph"]):
49
return False
50
return True
51
52
boards = board_list.BoardList().find_ap_periph_boards()
53
54
for board in boards:
55
if not fnmatch.fnmatch(board, args.pattern):
56
continue
57
print("Building for %s" % board)
58
if not build_board(board):
59
failed_boards.add(board)
60
if args.stop:
61
break
62
continue
63
64
if len(failed_boards):
65
print("Failed boards: %s" % list(failed_boards))
66
else:
67
print("No failed builds")
68
69
70