waf: allow build with ardupilot as a module

This commit is contained in:
bugobliterator 2021-12-06 10:22:46 +05:30 committed by Andrew Tridgell
parent 6fda5b946e
commit 9eb3a976bc
3 changed files with 20 additions and 4 deletions

View File

@ -439,6 +439,15 @@ def add_dynamic_boards_chibios():
if os.path.exists(hwdef):
newclass = type(d, (chibios,), {'name': d})
@conf
def get_chibios_board_cls(ctx, name, hwdef):
if name in _board_classes.keys():
_board_classes[name].hwdef = hwdef
return _board_classes[name]
newclass = type(name, (chibios,), {'name': name})
newclass.hwdef = hwdef
return newclass
def add_dynamic_boards_esp32():
'''add boards based on existance of hwdef.dat in subdirectories for ESP32'''
dirname, dirlist, filenames = next(os.walk('libraries/AP_HAL_ESP32/hwdef'))
@ -759,6 +768,8 @@ class chibios(Board):
toolchain = 'arm-none-eabi'
def configure_env(self, cfg, env):
if hasattr(self, 'hwdef'):
cfg.env.HWDEF = self.hwdef
super(chibios, self).configure_env(cfg, env)
cfg.load('chibios')

View File

@ -455,13 +455,18 @@ def configure(cfg):
def generate_hwdef_h(env):
'''run chibios_hwdef.py'''
import subprocess
if env.BOOTLOADER:
env.HWDEF = os.path.join(env.SRCROOT, 'libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef-bl.dat' % env.BOARD)
if len(env.HWDEF) == 0:
env.HWDEF = os.path.join(env.SRCROOT, 'libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef-bl.dat' % env.BOARD)
else:
# update to using hwdef-bl.dat
env.HWDEF = env.HWDEF.replace('hwdef.dat', 'hwdef-bl.dat')
env.BOOTLOADER_OPTION="--bootloader"
else:
env.HWDEF = os.path.join(env.SRCROOT, 'libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % env.BOARD)
if len(env.HWDEF) == 0:
env.HWDEF = os.path.join(env.SRCROOT, 'libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % env.BOARD)
env.BOOTLOADER_OPTION=""
hwdef_script = os.path.join(env.SRCROOT, 'libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py')
hwdef_out = env.BUILDROOT
if not os.path.exists(hwdef_out):

View File

@ -77,7 +77,7 @@ def process_mavgen(self):
if not hasattr(self, 'output_dir'):
self.bld.fatal('mavgen: missing option output_dir')
inputs = self.to_nodes(self.source)
inputs = self.to_nodes(self.bld.srcnode.find_node(self.source))
outputs = []
self.source = []