2021-08-05 06:43:16 -03:00
|
|
|
#!/usr/bin/env python
|
2021-08-29 23:59:15 -03:00
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
2022-08-19 05:51:38 -03:00
|
|
|
import fnmatch
|
2021-08-29 23:59:15 -03:00
|
|
|
|
2021-08-05 06:43:16 -03:00
|
|
|
'''
|
|
|
|
list of boards for build_binaries.py and custom build server
|
2021-08-29 23:59:15 -03:00
|
|
|
|
|
|
|
AP_FLAKE8_CLEAN
|
2021-08-05 06:43:16 -03:00
|
|
|
'''
|
|
|
|
|
2021-08-29 23:59:15 -03:00
|
|
|
|
|
|
|
class Board(object):
|
|
|
|
def __init__(self, name):
|
|
|
|
self.name = name
|
|
|
|
self.is_ap_periph = False
|
2022-02-24 01:34:08 -04:00
|
|
|
self.autobuild_targets = [
|
2022-03-10 18:07:27 -04:00
|
|
|
'Tracker',
|
2022-02-24 01:34:08 -04:00
|
|
|
'Blimp',
|
|
|
|
'Copter',
|
|
|
|
'Heli',
|
|
|
|
'Plane',
|
|
|
|
'Rover',
|
2022-03-10 04:02:33 -04:00
|
|
|
'Sub',
|
2022-02-24 01:34:08 -04:00
|
|
|
]
|
2021-08-29 23:59:15 -03:00
|
|
|
|
2022-08-20 07:27:18 -03:00
|
|
|
|
2022-08-19 05:51:38 -03:00
|
|
|
def in_blacklist(blacklist, b):
|
|
|
|
'''return true if board b is in the blacklist, including wildcards'''
|
|
|
|
for bl in blacklist:
|
|
|
|
if fnmatch.fnmatch(b, bl):
|
|
|
|
return True
|
|
|
|
return False
|
2021-08-29 23:59:15 -03:00
|
|
|
|
2022-08-20 07:27:18 -03:00
|
|
|
|
2021-08-29 23:59:15 -03:00
|
|
|
class BoardList(object):
|
|
|
|
|
2022-01-11 18:30:49 -04:00
|
|
|
def set_hwdef_dir(self):
|
2021-08-29 23:59:15 -03:00
|
|
|
self.hwdef_dir = os.path.join(
|
|
|
|
os.path.dirname(os.path.realpath(__file__)),
|
|
|
|
"..", "..", "libraries", "AP_HAL_ChibiOS", "hwdef")
|
|
|
|
|
2022-01-11 18:30:49 -04:00
|
|
|
if os.path.exists(self.hwdef_dir):
|
|
|
|
return
|
|
|
|
|
|
|
|
self.hwdef_dir = os.path.join(
|
|
|
|
os.path.dirname(os.path.realpath(__file__)),
|
|
|
|
"libraries", "AP_HAL_ChibiOS", "hwdef")
|
|
|
|
|
|
|
|
if os.path.exists(self.hwdef_dir):
|
|
|
|
# we're on the autotest server and have been copied in
|
|
|
|
# to the APM root directory
|
|
|
|
return
|
|
|
|
|
|
|
|
raise ValueError("Did not find hwdef_dir")
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.set_hwdef_dir()
|
2021-08-29 23:59:15 -03:00
|
|
|
|
|
|
|
# no hwdefs for Linux boards - yet?
|
|
|
|
self.boards = [
|
|
|
|
Board("erlebrain2"),
|
|
|
|
Board("navigator"),
|
|
|
|
Board("navio"),
|
|
|
|
Board("navio2"),
|
|
|
|
Board("edge"),
|
|
|
|
Board("obal"),
|
|
|
|
Board("pxf"),
|
2022-01-07 09:10:14 -04:00
|
|
|
Board("bbbmini"),
|
|
|
|
Board("blue"),
|
2021-08-29 23:59:15 -03:00
|
|
|
Board("pxfmini"),
|
|
|
|
Board("SITL_x86_64_linux_gnu"),
|
|
|
|
Board("SITL_arm_linux_gnueabihf"),
|
|
|
|
]
|
|
|
|
|
|
|
|
for adir in os.listdir(self.hwdef_dir):
|
|
|
|
if adir is None:
|
|
|
|
continue
|
|
|
|
if not os.path.isdir(os.path.join(self.hwdef_dir, adir)):
|
|
|
|
continue
|
|
|
|
if adir in ["scripts", "common", "STM32CubeConf"]:
|
|
|
|
continue
|
|
|
|
filepath = os.path.join(self.hwdef_dir, adir, "hwdef.dat")
|
|
|
|
if not os.path.exists(filepath):
|
|
|
|
continue
|
|
|
|
filepath = os.path.join(self.hwdef_dir, adir, "hwdef.dat")
|
|
|
|
text = self.read_hwdef(filepath)
|
|
|
|
|
|
|
|
board = Board(adir)
|
|
|
|
self.boards.append(board)
|
|
|
|
for line in text:
|
|
|
|
if re.match(r"^\s*env AP_PERIPH 1", line):
|
|
|
|
board.is_ap_periph = 1
|
2022-01-12 18:24:29 -04:00
|
|
|
if re.match(r"^\s*env AP_PERIPH_HEAVY 1", line):
|
|
|
|
board.is_ap_periph = 1
|
2021-08-29 23:59:15 -03:00
|
|
|
|
2022-02-24 01:34:08 -04:00
|
|
|
# a hwdef can specify which vehicles this target is valid for:
|
|
|
|
match = re.match(r"AUTOBUILD_TARGETS\s*(.*)", line)
|
|
|
|
if match is not None:
|
2022-04-05 22:18:32 -03:00
|
|
|
mname = match.group(1)
|
|
|
|
if mname.lower() == 'none':
|
|
|
|
board.autobuild_targets = []
|
|
|
|
else:
|
|
|
|
board.autobuild_targets = [
|
|
|
|
x.rstrip().lstrip().lower() for x in mname.split(",")
|
|
|
|
]
|
2022-02-24 01:34:08 -04:00
|
|
|
|
2021-08-29 23:59:15 -03:00
|
|
|
def read_hwdef(self, filepath):
|
|
|
|
fh = open(filepath)
|
|
|
|
ret = []
|
|
|
|
text = fh.readlines()
|
|
|
|
for line in text:
|
|
|
|
m = re.match(r"^\s*include\s+(.+)\s*$", line)
|
|
|
|
if m is not None:
|
|
|
|
ret += self.read_hwdef(os.path.join(os.path.dirname(filepath), m.group(1)))
|
|
|
|
else:
|
|
|
|
ret += [line]
|
|
|
|
return ret
|
|
|
|
|
2022-02-24 01:34:08 -04:00
|
|
|
def find_autobuild_boards(self, build_target=None):
|
2021-08-29 23:59:15 -03:00
|
|
|
ret = []
|
|
|
|
for board in self.boards:
|
|
|
|
if board.is_ap_periph:
|
|
|
|
continue
|
|
|
|
ret.append(board.name)
|
|
|
|
|
|
|
|
# these were missing in the original list for unknown reasons.
|
|
|
|
# Omitting them for backwards-compatability here - but we
|
|
|
|
# should probably have a line in the hwdef indicating they
|
|
|
|
# shouldn't be auto-built...
|
|
|
|
blacklist = [
|
2022-01-12 18:12:28 -04:00
|
|
|
# IOMCU:
|
|
|
|
"iomcu",
|
|
|
|
'iomcu_f103_8MHz',
|
|
|
|
|
|
|
|
# bdshot
|
|
|
|
"fmuv3-bdshot",
|
|
|
|
|
2022-08-26 08:34:40 -03:00
|
|
|
# renamed to KakuteH7Mini-Nand
|
|
|
|
"KakuteH7Miniv2",
|
|
|
|
|
2022-09-13 05:01:10 -03:00
|
|
|
# renamed to AtomRCF405NAVI
|
|
|
|
"AtomRCF405"
|
|
|
|
|
2022-01-12 18:12:28 -04:00
|
|
|
# other
|
|
|
|
"crazyflie2",
|
|
|
|
"CubeOrange-joey",
|
2021-08-29 23:59:15 -03:00
|
|
|
"luminousbee4",
|
2022-01-12 18:12:28 -04:00
|
|
|
"MazzyStarDrone",
|
|
|
|
"omnibusf4pro-one",
|
2021-08-29 23:59:15 -03:00
|
|
|
"skyviper-f412-rev1",
|
2022-08-19 05:51:38 -03:00
|
|
|
"*-ODID",
|
2022-08-22 01:35:29 -03:00
|
|
|
"*-ODID-heli",
|
2021-08-29 23:59:15 -03:00
|
|
|
]
|
|
|
|
|
2022-08-19 05:51:38 -03:00
|
|
|
ret = filter(lambda x : not in_blacklist(blacklist, x), ret)
|
2021-08-29 23:59:15 -03:00
|
|
|
|
2022-02-24 01:34:08 -04:00
|
|
|
# if the caller has supplied a vehicle to limit to then we do that here:
|
|
|
|
if build_target is not None:
|
|
|
|
# Slow down: n^2 algorithm ahead
|
|
|
|
newret = []
|
|
|
|
for x in ret:
|
|
|
|
for b in self.boards:
|
|
|
|
if b.name.lower() != x.lower():
|
|
|
|
continue
|
|
|
|
if build_target.lower() not in [y.lower() for y in b.autobuild_targets]:
|
|
|
|
continue
|
|
|
|
newret.append(x)
|
|
|
|
ret = newret
|
|
|
|
|
|
|
|
return sorted(list(ret))
|
2021-08-29 23:59:15 -03:00
|
|
|
|
|
|
|
def find_ap_periph_boards(self):
|
|
|
|
blacklist = [
|
|
|
|
"CubeOrange-periph-heavy",
|
|
|
|
"f103-HWESC",
|
2022-01-12 18:12:28 -04:00
|
|
|
"f103-Trigger",
|
|
|
|
"G4-ESC",
|
|
|
|
"HerePro",
|
2021-08-29 23:59:15 -03:00
|
|
|
]
|
|
|
|
ret = []
|
|
|
|
for x in self.boards:
|
|
|
|
if not x.is_ap_periph:
|
|
|
|
continue
|
|
|
|
if x.name in blacklist:
|
|
|
|
continue
|
|
|
|
ret.append(x.name)
|
2022-02-24 01:34:08 -04:00
|
|
|
return sorted(list(ret))
|
2021-08-29 23:59:15 -03:00
|
|
|
|
|
|
|
|
|
|
|
AUTOBUILD_BOARDS = BoardList().find_autobuild_boards()
|
|
|
|
AP_PERIPH_BOARDS = BoardList().find_ap_periph_boards()
|
2022-04-05 22:18:32 -03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2022-04-10 20:22:21 -03:00
|
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(description='list boards to build')
|
|
|
|
|
|
|
|
parser.add_argument('target')
|
|
|
|
parser.add_argument('--per-line', action='store_true', default=False, help='list one per line for use with xargs')
|
|
|
|
args = parser.parse_args()
|
2022-04-05 22:18:32 -03:00
|
|
|
board_list = BoardList()
|
2022-04-10 20:22:21 -03:00
|
|
|
target = args.target
|
|
|
|
if target == "AP_Periph":
|
|
|
|
blist = board_list.find_ap_periph_boards()
|
|
|
|
else:
|
|
|
|
blist = board_list.find_autobuild_boards(target)
|
|
|
|
blist = sorted(blist)
|
|
|
|
if args.per_line:
|
|
|
|
for b in blist:
|
|
|
|
print(b)
|
|
|
|
else:
|
|
|
|
print(blist)
|