Tools: allow specification of AUTOBUILD_TARGETS in hwdef files

This commit is contained in:
Peter Barker 2022-02-24 16:34:08 +11:00 committed by Peter Barker
parent 11f7cce978
commit cb6f9ea6a1
2 changed files with 42 additions and 18 deletions

View File

@ -14,6 +14,14 @@ class Board(object):
def __init__(self, name):
self.name = name
self.is_ap_periph = False
self.autobuild_targets = [
'AntennaTracker',
'Blimp',
'Copter',
'Heli',
'Plane',
'Rover',
]
class BoardList(object):
@ -77,6 +85,13 @@ class BoardList(object):
if re.match(r"^\s*env AP_PERIPH_HEAVY 1", line):
board.is_ap_periph = 1
# a hwdef can specify which vehicles this target is valid for:
match = re.match(r"AUTOBUILD_TARGETS\s*(.*)", line)
if match is not None:
board.autobuild_targets = [
x.rstrip().lstrip().lower() for x in match.group(1).split(",")
]
def read_hwdef(self, filepath):
fh = open(filepath)
ret = []
@ -89,7 +104,7 @@ class BoardList(object):
ret += [line]
return ret
def find_autobuild_boards(self):
def find_autobuild_boards(self, build_target=None):
ret = []
for board in self.boards:
if board.is_ap_periph:
@ -136,7 +151,20 @@ class BoardList(object):
ret = filter(lambda x : x not in blacklist, ret)
return list(ret)
# 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))
def find_ap_periph_boards(self):
blacklist = [
@ -159,7 +187,7 @@ class BoardList(object):
if x.name in blacklist:
continue
ret.append(x.name)
return list(ret)
return sorted(list(ret))
AUTOBUILD_BOARDS = BoardList().find_autobuild_boards()

View File

@ -27,7 +27,8 @@ import generate_manifest
import gen_stable
import build_binaries_history
from board_list import AUTOBUILD_BOARDS, AP_PERIPH_BOARDS
import board_list
from board_list import AP_PERIPH_BOARDS
if sys.version_info[0] < 3:
running_python3 = False
@ -67,6 +68,7 @@ class build_binaries(object):
def __init__(self, tags):
self.tags = tags
self.dirty = False
self.board_list = board_list.BoardList()
def progress(self, string):
'''pretty-print progress'''
@ -535,18 +537,15 @@ is bob we will attempt to checkout bob-AVR'''
self.progress("Exception caught: %s" %
self.get_exception_stacktrace(e))
def common_boards(self):
'''returns list of boards common to all vehicles'''
return AUTOBUILD_BOARDS
def AP_Periph_boards(self):
return AP_PERIPH_BOARDS
def build_arducopter(self, tag):
'''build Copter binaries'''
boards = []
boards.extend(["skyviper-v2450", "aerofc-v1", "bebop", "CubeSolo", "CubeGreen-solo", "skyviper-journey"])
boards.extend(self.common_boards()[:])
boards.extend(["aerofc-v1", "bebop"])
boards.extend(self.board_list.find_autobuild_boards('Copter'))
self.build_vehicle(tag,
"ArduCopter",
boards,
@ -556,7 +555,7 @@ is bob we will attempt to checkout bob-AVR'''
def build_arduplane(self, tag):
'''build Plane binaries'''
boards = self.common_boards()[:]
boards = self.board_list.find_autobuild_boards('Plane')[:]
boards.append("disco")
self.build_vehicle(tag,
"ArduPlane",
@ -566,19 +565,17 @@ is bob we will attempt to checkout bob-AVR'''
def build_antennatracker(self, tag):
'''build Tracker binaries'''
boards = self.common_boards()[:]
self.build_vehicle(tag,
"AntennaTracker",
boards,
self.board_list.find_autobuild_boards('Tracker')[:],
"AntennaTracker",
"antennatracker")
def build_rover(self, tag):
'''build Rover binaries'''
boards = self.common_boards()
self.build_vehicle(tag,
"Rover",
boards,
self.board_list.find_autobuild_boards('Rover')[:],
"Rover",
"ardurover")
@ -586,7 +583,7 @@ is bob we will attempt to checkout bob-AVR'''
'''build Sub binaries'''
self.build_vehicle(tag,
"ArduSub",
self.common_boards(),
self.board_list.find_autobuild_boards('Sub')[:],
"Sub",
"ardusub")
@ -601,10 +598,9 @@ is bob we will attempt to checkout bob-AVR'''
def build_blimp(self, tag):
'''build Blimp binaries'''
boards = self.common_boards()
self.build_vehicle(tag,
"Blimp",
boards,
self.board_list.find_autobuild_boards('Blimp')[:],
"Blimp",
"blimp")