Waf: add coverage flags

This commit is contained in:
Pierre Kancir 2021-05-21 10:51:31 +02:00 committed by Peter Barker
parent a5a25411da
commit d1cc8d2bf3
2 changed files with 26 additions and 0 deletions

View File

@ -164,6 +164,19 @@ class Board:
env.DEFINES.update( env.DEFINES.update(
HAL_DEBUG_BUILD = 1, HAL_DEBUG_BUILD = 1,
) )
if cfg.env.COVERAGE:
env.CFLAGS += [
'-fprofile-arcs',
'-ftest-coverage',
]
env.CXXFLAGS += [
'-fprofile-arcs',
'-ftest-coverage',
]
env.LINKFLAGS += [
'-lgcov',
'-coverage',
]
if cfg.options.bootloader: if cfg.options.bootloader:
# don't let bootloaders try and pull scripting in # don't let bootloaders try and pull scripting in

13
wscript
View File

@ -82,6 +82,11 @@ def options(opt):
default=False, default=False,
help='Configure as debug variant.') help='Configure as debug variant.')
g.add_option('--coverage',
action='store_true',
default=False,
help='Configure coverage flags.')
g.add_option('--Werror', g.add_option('--Werror',
action='store_true', action='store_true',
default=False, default=False,
@ -284,6 +289,7 @@ def configure(cfg):
cfg.env.BOARD = cfg.options.board cfg.env.BOARD = cfg.options.board
cfg.env.DEBUG = cfg.options.debug cfg.env.DEBUG = cfg.options.debug
cfg.env.COVERAGE = cfg.options.coverage
cfg.env.AUTOCONFIG = cfg.options.autoconfig cfg.env.AUTOCONFIG = cfg.options.autoconfig
_set_build_context_variant(cfg.env.BOARD) _set_build_context_variant(cfg.env.BOARD)
@ -291,6 +297,7 @@ def configure(cfg):
cfg.env.BOARD = cfg.options.board cfg.env.BOARD = cfg.options.board
cfg.env.DEBUG = cfg.options.debug cfg.env.DEBUG = cfg.options.debug
cfg.env.COVERAGE = cfg.options.coverage
cfg.env.ENABLE_ASSERTS = cfg.options.enable_asserts cfg.env.ENABLE_ASSERTS = cfg.options.enable_asserts
cfg.env.BOOTLOADER = cfg.options.bootloader cfg.env.BOOTLOADER = cfg.options.bootloader
cfg.env.ENABLE_MALLOC_GUARD = cfg.options.enable_malloc_guard cfg.env.ENABLE_MALLOC_GUARD = cfg.options.enable_malloc_guard
@ -368,6 +375,12 @@ def configure(cfg):
else: else:
cfg.end_msg('disabled', color='YELLOW') cfg.end_msg('disabled', color='YELLOW')
cfg.start_msg('Coverage build')
if cfg.env.COVERAGE:
cfg.end_msg('enabled')
else:
cfg.end_msg('disabled', color='YELLOW')
cfg.env.append_value('GIT_SUBMODULES', 'mavlink') cfg.env.append_value('GIT_SUBMODULES', 'mavlink')
cfg.env.prepend_value('INCLUDES', [ cfg.env.prepend_value('INCLUDES', [