Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waf: tidy interpretation of -Werror #24447

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions Tools/ardupilotwaf/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,22 +774,31 @@ def configure_env(self, cfg, env):
# whitelist of compilers which we should build with -Werror
gcc_whitelist = frozenset([
('11','3','0'),
('12','1','0'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ubuntu 23 has 12.2.0 did you mean to add that instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add this, the build will fail, because of #24142

])

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__

Expand Down
4 changes: 2 additions & 2 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ def options(opt):

g.add_option('--Werror',
action='store_true',
default=False,
default=None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to use None make a lot more sense in the logic because it was impossible to tell if the CLI overrode the default or not. Great change Peter.

help='build with -Werror.')

g.add_option('--disable-Werror',
action='store_true',
default=True,
default=None,
help='Disable -Werror.')

g.add_option('--toolchain',
Expand Down