waf: Fix disable werror to actually work

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
This commit is contained in:
Ryan Friedman 2023-05-29 19:42:12 -06:00 committed by Andrew Tridgell
parent 819f93b778
commit fd10bc35f0
2 changed files with 13 additions and 9 deletions

View File

@ -780,13 +780,18 @@ class sitl(Board):
('11','3','0'), ('11','3','0'),
]) ])
if cfg.options.Werror or cfg.env.CC_VERSION in gcc_whitelist: if cfg.env.CC_VERSION in gcc_whitelist or cfg.options.Werror:
cfg.msg("Enabling -Werror", "yes") if not cfg.options.disable_Werror:
if '-Werror' not in env.CXXFLAGS: cfg.msg("Enabling -Werror", "yes")
env.CXXFLAGS += [ '-Werror' ] 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: else:
cfg.msg("Enabling -Werror", "no") cfg.msg("Enabling -Werror", "yes")
def get_name(self): def get_name(self):
return self.__class__.__name__ return self.__class__.__name__

View File

@ -590,10 +590,9 @@ def configure(cfg):
cfg.define('_GNU_SOURCE', 1) cfg.define('_GNU_SOURCE', 1)
if cfg.options.Werror: if cfg.options.Werror:
# print(cfg.options.Werror)
if cfg.options.disable_Werror: if cfg.options.disable_Werror:
raise ValueError("Cannot enable and disable Werror at the same time") cfg.options.Werror = False
else:
cfg.options.Werror = not cfg.options.disable_Werror
cfg.write_config_header(os.path.join(cfg.variant, 'ap_config.h'), guard='_AP_CONFIG_H_') cfg.write_config_header(os.path.join(cfg.variant, 'ap_config.h'), guard='_AP_CONFIG_H_')