From c5f3beb2977b5bac1b6cc18403cfa7bc3d875762 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 2 Aug 2018 15:22:30 +1000 Subject: [PATCH] waf: added --enable-asserts option for ChibiOS --- Tools/ardupilotwaf/boards.py | 7 +++++++ Tools/ardupilotwaf/chibios.py | 3 +++ wscript | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index 0e9203595d..8e217abed3 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -405,6 +405,13 @@ class chibios(Board): '-g', ] + if cfg.env.ENABLE_ASSERTS: + cfg.msg("Enabling ChibiOS asserts", "yes") + env.CFLAGS += [ '-DHAL_CHIBIOS_ENABLE_ASSERTS' ] + env.CXXFLAGS += [ '-DHAL_CHIBIOS_ENABLE_ASSERTS' ] + else: + cfg.msg("Enabling ChibiOS asserts", "no") + env.LIB += ['gcc', 'm'] env.GIT_SUBMODULES += [ diff --git a/Tools/ardupilotwaf/chibios.py b/Tools/ardupilotwaf/chibios.py index c10aaad520..feb2e2f163 100644 --- a/Tools/ardupilotwaf/chibios.py +++ b/Tools/ardupilotwaf/chibios.py @@ -215,6 +215,8 @@ def load_env_vars(env): else: env[k] = v print("env set %s=%s" % (k, v)) + if env.ENABLE_ASSERTS: + env.CHIBIOS_BUILD_FLAGS += ' ENABLE_ASSERTS=yes' def configure(cfg): cfg.find_program('make', var='MAKE') @@ -294,6 +296,7 @@ def pre_build(bld): bld.get_board().with_uavcan = True 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(bld.env.HWDEF), diff --git a/wscript b/wscript index 1749cd72cc..aa0a687142 100644 --- a/wscript +++ b/wscript @@ -67,6 +67,11 @@ def options(opt): default=False, help='Configure as debug variant.') + g.add_option('--enable-asserts', + action='store_true', + default=False, + help='enable OS level asserts.') + g.add_option('--bootloader', action='store_true', default=False, @@ -176,6 +181,7 @@ def configure(cfg): cfg.env.BOARD = cfg.options.board cfg.env.DEBUG = cfg.options.debug + cfg.env.ENABLE_ASSERTS = cfg.options.enable_asserts cfg.env.BOOTLOADER = cfg.options.bootloader # Allow to differentiate our build from the make build