waf: added --enable-memory-guard option

This commit is contained in:
Andrew Tridgell 2020-11-13 16:09:37 +11:00 committed by Peter Barker
parent 70a8853e6a
commit ce95b7e81a
3 changed files with 16 additions and 0 deletions

View File

@ -663,6 +663,13 @@ class chibios(Board):
else:
cfg.msg("Enabling ChibiOS asserts", "no")
if cfg.env.ENABLE_MALLOC_GUARD:
cfg.msg("Enabling malloc guard", "yes")
env.CFLAGS += [ '-DHAL_CHIBIOS_ENABLE_MALLOC_GUARD' ]
env.CXXFLAGS += [ '-DHAL_CHIBIOS_ENABLE_MALLOC_GUARD' ]
else:
cfg.msg("Enabling malloc guard", "no")
env.LIB += ['gcc', 'm']
env.GIT_SUBMODULES += [

View File

@ -292,6 +292,9 @@ def load_env_vars(env):
print("env set %s=%s" % (k, v))
if env.ENABLE_ASSERTS:
env.CHIBIOS_BUILD_FLAGS += ' ENABLE_ASSERTS=yes'
if env.ENABLE_MALLOC_GUARD:
env.CHIBIOS_BUILD_FLAGS += ' ENABLE_MALLOC_GUARD=yes'
def setup_optimization(env):
'''setup optimization flags for build'''

View File

@ -96,6 +96,11 @@ def options(opt):
default=False,
help='enable OS level asserts.')
g.add_option('--enable-malloc-guard',
action='store_true',
default=False,
help='enable malloc guard regions.')
g.add_option('--bootloader',
action='store_true',
default=False,
@ -277,6 +282,7 @@ def configure(cfg):
cfg.env.DEBUG = cfg.options.debug
cfg.env.ENABLE_ASSERTS = cfg.options.enable_asserts
cfg.env.BOOTLOADER = cfg.options.bootloader
cfg.env.ENABLE_MALLOC_GUARD = cfg.options.enable_malloc_guard
cfg.env.OPTIONS = cfg.options.__dict__