waf: tidy interpretation of -Werror

This commit is contained in:
Peter Barker 2023-07-31 11:00:50 +10:00 committed by Andrew Tridgell
parent 09a59bc934
commit 46b262cb32
2 changed files with 23 additions and 14 deletions

View File

@ -774,21 +774,30 @@ class sitl(Board):
# whitelist of compilers which we should build with -Werror
gcc_whitelist = frozenset([
('11','3','0'),
('12','1','0'),
])
werr_enabled_default = bool('g++' == cfg.env.COMPILER_CXX and cfg.env.CC_VERSION in gcc_whitelist)
# initialise werr_enabled from defaults:
werr_enabled = bool('g++' in cfg.env.COMPILER_CXX and cfg.env.CC_VERSION in gcc_whitelist)
if werr_enabled_default or cfg.options.Werror:
if not cfg.options.disable_Werror:
cfg.msg("Enabling -Werror", "yes")
if '-Werror' not in env.CXXFLAGS:
env.CXXFLAGS += [ '-Werror' ]
else:
cfg.msg("Enabling -Werror", "no")
if '-Werror' in env.CXXFLAGS:
env.CXXFLAGS.remove('-Werror')
else:
# now process overrides to that default:
if (cfg.options.Werror is not None and
cfg.options.Werror == cfg.options.disable_Werror):
cfg.fatal("Asked to both enable and disable Werror")
if cfg.options.Werror is not None:
werr_enabled = cfg.options.Werror
elif cfg.options.disable_Werror is not None:
werr_enabled = not cfg.options.disable_Werror
if werr_enabled:
cfg.msg("Enabling -Werror", "yes")
if '-Werror' not in env.CXXFLAGS:
env.CXXFLAGS += [ '-Werror' ]
else:
cfg.msg("Enabling -Werror", "no")
if '-Werror' in env.CXXFLAGS:
env.CXXFLAGS.remove('-Werror')
def get_name(self):
return self.__class__.__name__

View File

@ -143,12 +143,12 @@ def options(opt):
g.add_option('--Werror',
action='store_true',
default=False,
default=None,
help='build with -Werror.')
g.add_option('--disable-Werror',
action='store_true',
default=True,
default=None,
help='Disable -Werror.')
g.add_option('--toolchain',