diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2019-07-09 23:02:12 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-07-10 01:05:47 +0300 |
commit | 724113849c1eed224a0a1edea70a9cc4bab93229 (patch) | |
tree | 3c70a5810da60cfc1ab2c40ea537453647a31270 | |
parent | 4b25253bfd85bf1320486d1843a640975e388613 (diff) | |
download | meson-724113849c1eed224a0a1edea70a9cc4bab93229.zip meson-724113849c1eed224a0a1edea70a9cc4bab93229.tar.gz meson-724113849c1eed224a0a1edea70a9cc4bab93229.tar.bz2 |
Warn if the user manually adds arguments we have builtin support for.
-rw-r--r-- | mesonbuild/interpreter.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index f5bb4e5..a20dcd5 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3853,6 +3853,23 @@ different subdirectory. for_machine = self.machine_from_native_kwarg(kwargs) self.add_project_arguments(node, self.build.projects_link_args[for_machine], args, kwargs) + def warn_about_builtin_args(self, args): + warnargs = ('/W1', '/W2', '/W3', '/W4', '/Wall', '-Wall', '-Wextra', '-Wpedantic') + optargs = ('-O0', '-O2', '-O3', '-Os', '/O1', '/O2', '/Os') + for arg in args: + if arg in warnargs: + mlog.warning("Consider using the builtin warning_level option instead of adding warning flags by hand.") + elif arg in optargs: + mlog.warning('Consider using the builtin optimization level rather than adding flags by hand.') + elif arg == '-g': + mlog.warning('Consider using the builtin debug option rather than adding flags by hand.') + elif arg == '-pipe': + mlog.warning("You don't need to add -pipe, Meson will use it automatically when it is available.") + elif arg.startswith('-fsanitize'): + mlog.warning('Consider using the builtin option for sanitizers rather than adding flags by hand.') + elif arg.startswith('-std=') or arg.startswith('/std:'): + mlog.warning('Consider using the builtin option for language standard version rather than adding flags by hand.') + def add_global_arguments(self, node, argsdict, args, kwargs): if self.is_subproject(): msg = 'Function \'{}\' cannot be used in subprojects because ' \ @@ -3881,6 +3898,8 @@ different subdirectory. if 'language' not in kwargs: raise InvalidCode('Missing language definition in {}'.format(node.func_name)) + self.warn_about_builtin_args(args) + for lang in mesonlib.stringlistify(kwargs['language']): lang = lang.lower() argsdict[lang] = argsdict.get(lang, []) + args |