From 0ae25787c037944b5ab771dd05764ebc2c9aa3c2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 16 Jun 2018 20:00:54 +1000 Subject: [PATCH] waf: added a --bootloader configure option this selects hwdef-bl.dat instead of hwdef.dat, allowing for bootloader config to be kept in the same directory as the main hwdef.dat --- Tools/ardupilotwaf/chibios.py | 13 ++++++++----- wscript | 8 ++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Tools/ardupilotwaf/chibios.py b/Tools/ardupilotwaf/chibios.py index 92dfa6f0c5..bee0a60ac5 100644 --- a/Tools/ardupilotwaf/chibios.py +++ b/Tools/ardupilotwaf/chibios.py @@ -236,13 +236,16 @@ def configure(cfg): # that is needed by the remaining configure checks import subprocess - hwdef = srcpath('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % env.BOARD) + if env.BOOTLOADER: + env.HWDEF = srcpath('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef-bl.dat' % env.BOARD) + else: + env.HWDEF = srcpath('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % env.BOARD) hwdef_script = srcpath('libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py') hwdef_out = env.BUILDROOT if not os.path.exists(hwdef_out): os.mkdir(hwdef_out) try: - cmd = "python '{0}' -D '{1}' '{2}'".format(hwdef_script, hwdef_out, hwdef) + cmd = "python '{0}' -D '{1}' '{2}'".format(hwdef_script, hwdef_out, env.HWDEF) ret = subprocess.call(cmd, shell=True) except Exception: cfg.fatal("Failed to process hwdef.dat") @@ -259,11 +262,11 @@ def pre_build(bld): if bld.env.HAL_WITH_UAVCAN: bld.get_board().with_uavcan = True -def build(bld): +def build(bld): bld( # build hwdef.h and apj.prototype from hwdef.dat. This is needed after a waf clean - source=bld.path.ant_glob('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % bld.env.get_flat('BOARD')), - rule="python '${AP_HAL_ROOT}/hwdef/scripts/chibios_hwdef.py' -D '${BUILDROOT}' '${AP_HAL_ROOT}/hwdef/${BOARD}/hwdef.dat'", + source=bld.path.ant_glob(bld.env.HWDEF), + rule="python '${AP_HAL_ROOT}/hwdef/scripts/chibios_hwdef.py' -D '${BUILDROOT}' %s" % bld.env.HWDEF, group='dynamic_sources', target=['hwdef.h', 'apj.prototype', 'ldscript.ld'] ) diff --git a/wscript b/wscript index 4a27bcfbac..969e70d50c 100644 --- a/wscript +++ b/wscript @@ -67,6 +67,11 @@ def options(opt): default=False, help='Configure as debug variant.') + g.add_option('--bootloader', + action='store_true', + default=False, + help='Configure for building a bootloader.') + g.add_option('--no-autoconfig', dest='autoconfig', action='store_false', @@ -161,12 +166,15 @@ def configure(cfg): cfg.env.AUTOCONFIG = cfg.options.autoconfig cfg.env.VARIANT = cfg.env.BOARD + if cfg.options.bootloader: + cfg.env.VARIANT += '-bootloader' _set_build_context_variant(cfg.env.VARIANT) cfg.setenv(cfg.env.VARIANT) cfg.env.BOARD = cfg.options.board cfg.env.DEBUG = cfg.options.debug + cfg.env.BOOTLOADER = cfg.options.bootloader # Allow to differentiate our build from the make build cfg.define('WAF_BUILD', 1)