diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index 75e98270bb..8b8747d670 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -122,6 +122,7 @@ class Board: '-Werror=parentheses', '-Werror=format-extra-args', '-Werror=ignored-qualifiers', + '-DARDUPILOT_BUILD', ] if cfg.options.scripting_checks: @@ -205,6 +206,7 @@ class Board: '-Wfatal-errors', '-Wno-trigraphs', '-Werror=parentheses', + '-DARDUPILOT_BUILD', ] if 'clang++' in cfg.env.COMPILER_CXX: @@ -249,6 +251,15 @@ class Board: '-Werror=implicit-fallthrough', ] + if cfg.options.Werror: + errors = ['-Werror', + '-Werror=missing-declarations', + '-Werror=float-equal', + '-Werror=undef', + ] + env.CFLAGS += errors + env.CXXFLAGS += errors + if cfg.env.DEBUG: env.CXXFLAGS += [ '-g', @@ -481,11 +492,6 @@ class chibios(Board): '-Wframe-larger-than=1300', '-fsingle-precision-constant', '-Wno-attributes', - '-Wno-error=double-promotion', - '-Wno-error=missing-declarations', - '-Wno-error=float-equal', - '-Wno-error=undef', - '-Wno-error=cpp', '-fno-exceptions', '-Wall', '-Wextra', @@ -521,6 +527,15 @@ class chibios(Board): '-D__USE_CMSIS', '-Werror=deprecated-declarations' ] + if not cfg.options.Werror: + env.CFLAGS += [ + '-Wno-error=double-promotion', + '-Wno-error=missing-declarations', + '-Wno-error=float-equal', + '-Wno-error=undef', + '-Wno-error=cpp', + ] + env.CXXFLAGS += env.CFLAGS + [ '-fno-rtti', '-fno-threadsafe-statics', diff --git a/wscript b/wscript index c420f3054f..8d160e4162 100644 --- a/wscript +++ b/wscript @@ -76,6 +76,11 @@ def options(opt): default=False, help='Configure as debug variant.') + g.add_option('--Werror', + action='store_true', + default=False, + help='build with -Werror.') + g.add_option('--toolchain', action='store', default=None,