Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/scripts/board_list.py
Views: 1798
#!/usr/bin/env python312import os3import re4import fnmatch56'''7list of boards for build_binaries.py and custom build server89AP_FLAKE8_CLEAN10'''111213class Board(object):14def __init__(self, name):15self.name = name16self.is_ap_periph = False17self.autobuild_targets = [18'Tracker',19'Blimp',20'Copter',21'Heli',22'Plane',23'Rover',24'Sub',25]262728def in_blacklist(blacklist, b):29'''return true if board b is in the blacklist, including wildcards'''30for bl in blacklist:31if fnmatch.fnmatch(b, bl):32return True33return False343536class BoardList(object):3738def set_hwdef_dir(self):39self.hwdef_dir = os.path.join(40os.path.dirname(os.path.realpath(__file__)),41"..", "..", "libraries", "AP_HAL_ChibiOS", "hwdef")4243if os.path.exists(self.hwdef_dir):44return4546self.hwdef_dir = os.path.join(47os.path.dirname(os.path.realpath(__file__)),48"libraries", "AP_HAL_ChibiOS", "hwdef")4950if os.path.exists(self.hwdef_dir):51# we're on the autotest server and have been copied in52# to the APM root directory53return5455raise ValueError("Did not find hwdef_dir")5657def __init__(self):58self.set_hwdef_dir()5960# no hwdefs for Linux boards - yet?61self.boards = [62Board("erlebrain2"),63Board("navigator"),64Board("navigator64"),65Board("navio"),66Board("navio2"),67Board("edge"),68Board("obal"),69Board("pxf"),70Board("bbbmini"),71Board("bebop"),72Board("blue"),73Board("pxfmini"),74Board("canzero"),75Board("SITL_x86_64_linux_gnu"),76Board("SITL_arm_linux_gnueabihf"),77]7879for adir in os.listdir(self.hwdef_dir):80if adir is None:81continue82if not os.path.isdir(os.path.join(self.hwdef_dir, adir)):83continue84if adir in ["scripts", "common", "STM32CubeConf"]:85continue86filepath = os.path.join(self.hwdef_dir, adir, "hwdef.dat")87if not os.path.exists(filepath):88continue89filepath = os.path.join(self.hwdef_dir, adir, "hwdef.dat")90text = self.read_hwdef(filepath)9192board = Board(adir)93self.boards.append(board)94for line in text:95if re.match(r"^\s*env AP_PERIPH 1", line):96board.is_ap_periph = 197if re.match(r"^\s*env AP_PERIPH_HEAVY 1", line):98board.is_ap_periph = 199100# a hwdef can specify which vehicles this target is valid for:101match = re.match(r"AUTOBUILD_TARGETS\s*(.*)", line)102if match is not None:103mname = match.group(1)104if mname.lower() == 'none':105board.autobuild_targets = []106else:107board.autobuild_targets = [108x.rstrip().lstrip().lower() for x in mname.split(",")109]110111def read_hwdef(self, filepath):112fh = open(filepath)113ret = []114text = fh.readlines()115for line in text:116m = re.match(r"^\s*include\s+(.+)\s*$", line)117if m is not None:118ret += self.read_hwdef(os.path.join(os.path.dirname(filepath), m.group(1)))119else:120ret += [line]121return ret122123def find_autobuild_boards(self, build_target=None):124ret = []125for board in self.boards:126if board.is_ap_periph:127continue128ret.append(board.name)129130# these were missing in the original list for unknown reasons.131# Omitting them for backwards-compatability here - but we132# should probably have a line in the hwdef indicating they133# shouldn't be auto-built...134blacklist = [135# IOMCU:136"iomcu",137'iomcu_f103_8MHz',138139# bdshot140"fmuv3-bdshot",141142# renamed to KakuteH7Mini-Nand143"KakuteH7Miniv2",144145# renamed to AtomRCF405NAVI146"AtomRCF405"147148# other149"crazyflie2",150"CubeOrange-joey",151"luminousbee4",152"MazzyStarDrone",153"omnibusf4pro-one",154"skyviper-f412-rev1",155"SkystarsH7HD",156"*-ODID",157"*-ODID-heli",158]159160ret = filter(lambda x : not in_blacklist(blacklist, x), ret)161162# if the caller has supplied a vehicle to limit to then we do that here:163if build_target is not None:164# Slow down: n^2 algorithm ahead165newret = []166for x in ret:167for b in self.boards:168if b.name.lower() != x.lower():169continue170if build_target.lower() not in [y.lower() for y in b.autobuild_targets]:171continue172newret.append(x)173ret = newret174175return sorted(list(ret))176177def find_ap_periph_boards(self):178blacklist = [179"CubeOrange-periph-heavy",180"f103-HWESC",181"f103-Trigger",182"G4-ESC",183]184ret = []185for x in self.boards:186if not x.is_ap_periph:187continue188if x.name in blacklist:189continue190ret.append(x.name)191return sorted(list(ret))192193194AUTOBUILD_BOARDS = BoardList().find_autobuild_boards()195AP_PERIPH_BOARDS = BoardList().find_ap_periph_boards()196197if __name__ == '__main__':198import argparse199parser = argparse.ArgumentParser(description='list boards to build')200201parser.add_argument('target')202parser.add_argument('--per-line', action='store_true', default=False, help='list one per line for use with xargs')203args = parser.parse_args()204board_list = BoardList()205target = args.target206if target == "AP_Periph":207blist = board_list.find_ap_periph_boards()208else:209blist = board_list.find_autobuild_boards(target)210blist = sorted(blist)211if args.per_line:212for b in blist:213print(b)214else:215print(blist)216217218