waf: added --enable-asserts option for ChibiOS

This commit is contained in:
Andrew Tridgell 2018-08-02 15:22:30 +10:00
parent c63414442d
commit c5f3beb297
3 changed files with 16 additions and 0 deletions

View File

@ -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 += [

View File

@ -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),

View File

@ -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