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/board_list.py
Views: 1798
1
#!/usr/bin/env python3
2
3
import os
4
import re
5
import fnmatch
6
7
'''
8
list of boards for build_binaries.py and custom build server
9
10
AP_FLAKE8_CLEAN
11
'''
12
13
14
class Board(object):
15
def __init__(self, name):
16
self.name = name
17
self.is_ap_periph = False
18
self.autobuild_targets = [
19
'Tracker',
20
'Blimp',
21
'Copter',
22
'Heli',
23
'Plane',
24
'Rover',
25
'Sub',
26
]
27
28
29
def in_blacklist(blacklist, b):
30
'''return true if board b is in the blacklist, including wildcards'''
31
for bl in blacklist:
32
if fnmatch.fnmatch(b, bl):
33
return True
34
return False
35
36
37
class BoardList(object):
38
39
def set_hwdef_dir(self):
40
self.hwdef_dir = os.path.join(
41
os.path.dirname(os.path.realpath(__file__)),
42
"..", "..", "libraries", "AP_HAL_ChibiOS", "hwdef")
43
44
if os.path.exists(self.hwdef_dir):
45
return
46
47
self.hwdef_dir = os.path.join(
48
os.path.dirname(os.path.realpath(__file__)),
49
"libraries", "AP_HAL_ChibiOS", "hwdef")
50
51
if os.path.exists(self.hwdef_dir):
52
# we're on the autotest server and have been copied in
53
# to the APM root directory
54
return
55
56
raise ValueError("Did not find hwdef_dir")
57
58
def __init__(self):
59
self.set_hwdef_dir()
60
61
# no hwdefs for Linux boards - yet?
62
self.boards = [
63
Board("erlebrain2"),
64
Board("navigator"),
65
Board("navigator64"),
66
Board("navio"),
67
Board("navio2"),
68
Board("edge"),
69
Board("obal"),
70
Board("pxf"),
71
Board("bbbmini"),
72
Board("bebop"),
73
Board("blue"),
74
Board("pxfmini"),
75
Board("canzero"),
76
Board("SITL_x86_64_linux_gnu"),
77
Board("SITL_arm_linux_gnueabihf"),
78
]
79
80
for adir in os.listdir(self.hwdef_dir):
81
if adir is None:
82
continue
83
if not os.path.isdir(os.path.join(self.hwdef_dir, adir)):
84
continue
85
if adir in ["scripts", "common", "STM32CubeConf"]:
86
continue
87
filepath = os.path.join(self.hwdef_dir, adir, "hwdef.dat")
88
if not os.path.exists(filepath):
89
continue
90
filepath = os.path.join(self.hwdef_dir, adir, "hwdef.dat")
91
text = self.read_hwdef(filepath)
92
93
board = Board(adir)
94
self.boards.append(board)
95
for line in text:
96
if re.match(r"^\s*env AP_PERIPH 1", line):
97
board.is_ap_periph = 1
98
if re.match(r"^\s*env AP_PERIPH_HEAVY 1", line):
99
board.is_ap_periph = 1
100
101
# a hwdef can specify which vehicles this target is valid for:
102
match = re.match(r"AUTOBUILD_TARGETS\s*(.*)", line)
103
if match is not None:
104
mname = match.group(1)
105
if mname.lower() == 'none':
106
board.autobuild_targets = []
107
else:
108
board.autobuild_targets = [
109
x.rstrip().lstrip().lower() for x in mname.split(",")
110
]
111
112
def read_hwdef(self, filepath):
113
fh = open(filepath)
114
ret = []
115
text = fh.readlines()
116
for line in text:
117
m = re.match(r"^\s*include\s+(.+)\s*$", line)
118
if m is not None:
119
ret += self.read_hwdef(os.path.join(os.path.dirname(filepath), m.group(1)))
120
else:
121
ret += [line]
122
return ret
123
124
def find_autobuild_boards(self, build_target=None):
125
ret = []
126
for board in self.boards:
127
if board.is_ap_periph:
128
continue
129
ret.append(board.name)
130
131
# these were missing in the original list for unknown reasons.
132
# Omitting them for backwards-compatability here - but we
133
# should probably have a line in the hwdef indicating they
134
# shouldn't be auto-built...
135
blacklist = [
136
# IOMCU:
137
"iomcu",
138
'iomcu_f103_8MHz',
139
140
# bdshot
141
"fmuv3-bdshot",
142
143
# renamed to KakuteH7Mini-Nand
144
"KakuteH7Miniv2",
145
146
# renamed to AtomRCF405NAVI
147
"AtomRCF405"
148
149
# other
150
"crazyflie2",
151
"CubeOrange-joey",
152
"luminousbee4",
153
"MazzyStarDrone",
154
"omnibusf4pro-one",
155
"skyviper-f412-rev1",
156
"SkystarsH7HD",
157
"*-ODID",
158
"*-ODID-heli",
159
]
160
161
ret = filter(lambda x : not in_blacklist(blacklist, x), ret)
162
163
# if the caller has supplied a vehicle to limit to then we do that here:
164
if build_target is not None:
165
# Slow down: n^2 algorithm ahead
166
newret = []
167
for x in ret:
168
for b in self.boards:
169
if b.name.lower() != x.lower():
170
continue
171
if build_target.lower() not in [y.lower() for y in b.autobuild_targets]:
172
continue
173
newret.append(x)
174
ret = newret
175
176
return sorted(list(ret))
177
178
def find_ap_periph_boards(self):
179
blacklist = [
180
"CubeOrange-periph-heavy",
181
"f103-HWESC",
182
"f103-Trigger",
183
"G4-ESC",
184
]
185
ret = []
186
for x in self.boards:
187
if not x.is_ap_periph:
188
continue
189
if x.name in blacklist:
190
continue
191
ret.append(x.name)
192
return sorted(list(ret))
193
194
195
AUTOBUILD_BOARDS = BoardList().find_autobuild_boards()
196
AP_PERIPH_BOARDS = BoardList().find_ap_periph_boards()
197
198
if __name__ == '__main__':
199
import argparse
200
parser = argparse.ArgumentParser(description='list boards to build')
201
202
parser.add_argument('target')
203
parser.add_argument('--per-line', action='store_true', default=False, help='list one per line for use with xargs')
204
args = parser.parse_args()
205
board_list = BoardList()
206
target = args.target
207
if target == "AP_Periph":
208
blist = board_list.find_ap_periph_boards()
209
else:
210
blist = board_list.find_autobuild_boards(target)
211
blist = sorted(blist)
212
if args.per_line:
213
for b in blist:
214
print(b)
215
else:
216
print(blist)
217
218