Make the hint about built-in options more useful

In a large project, it can be hard to guess what meson "had in mind", when many different
warnings are added in different places. Let's make the message precise and specify the location.

WARNING: Consider using the built-in warning_level option instead of adding warning flags by hand.
↓
meson.build:414: WARNING: Consider using the built-in warning_level option instead of using "-Wextra".
pull/6159/head
Zbigniew Jędrzejewski-Szmek 5 years ago committed by Jussi Pakkanen
parent d55aaa56f4
commit 74151ead9a
  1. 18
      mesonbuild/interpreter.py

@ -3958,17 +3958,23 @@ different subdirectory.
optargs = ('-O0', '-O2', '-O3', '-Os', '/O1', '/O2', '/Os')
for arg in args:
if arg in warnargs:
mlog.warning("Consider using the built-in warning_level option instead of adding warning flags by hand.")
mlog.warning('Consider using the built-in warning_level option instead of using "{}".'.format(arg),
location=self.current_node)
elif arg in optargs:
mlog.warning('Consider using the built-in optimization level rather than adding flags by hand.')
mlog.warning('Consider using the built-in optimization level instead of using "{}".'.format(arg),
location=self.current_node)
elif arg == '-g':
mlog.warning('Consider using the built-in debug option rather than adding flags by hand.')
mlog.warning('Consider using the built-in debug option instead of using "{}".'.format(arg),
location=self.current_node)
elif arg == '-pipe':
mlog.warning("You don't need to add -pipe, Meson will use it automatically when it is available.")
mlog.warning("You don't need to add -pipe, Meson will use it automatically when it is available.",
location=self.current_node)
elif arg.startswith('-fsanitize'):
mlog.warning('Consider using the built-in option for sanitizers rather than adding flags by hand.')
mlog.warning('Consider using the built-in option for sanitizers instead of using "{}".'.format(arg),
location=self.current_node)
elif arg.startswith('-std=') or arg.startswith('/std:'):
mlog.warning('Consider using the built-in option for language standard version rather than adding flags by hand.')
mlog.warning('Consider using the built-in option for language standard version instead of using "{}".'.format(arg),
location=self.current_node)
def add_global_arguments(self, node, argsdict, args, kwargs):
if self.is_subproject():

Loading…
Cancel
Save