diff options
author | Laurin-Luis Lehning <65224843+e820@users.noreply.github.com> | 2021-06-18 01:42:57 +0200 |
---|---|---|
committer | Laurin-Luis Lehning <65224843+e820@users.noreply.github.com> | 2021-06-21 09:15:13 +0200 |
commit | d5ed8f61a5cd7a5d384ccd59abc219154a00d42c (patch) | |
tree | a1760fcec149f9c06e27ca98f86e028a5c736f4a /mesonbuild/interpreter/compiler.py | |
parent | 377adfb6fbf526c56b595ef09840d5b59168162a (diff) | |
download | meson-d5ed8f61a5cd7a5d384ccd59abc219154a00d42c.zip meson-d5ed8f61a5cd7a5d384ccd59abc219154a00d42c.tar.gz meson-d5ed8f61a5cd7a5d384ccd59abc219154a00d42c.tar.bz2 |
interpreter: Move argument checks from add_*_arguments to compiler.get_supported_arguments
Diffstat (limited to 'mesonbuild/interpreter/compiler.py')
-rw-r--r-- | mesonbuild/interpreter/compiler.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py index bf32be3..9a6beeb 100644 --- a/mesonbuild/interpreter/compiler.py +++ b/mesonbuild/interpreter/compiler.py @@ -1,4 +1,5 @@ import functools +from mesonbuild.interpreterbase.decorators import typed_kwargs, KwargInfo from .interpreterobjects import (extract_required_kwarg, extract_search_dirs) @@ -684,12 +685,24 @@ class CompilerHolder(ObjectHolder['Compiler']): return result @FeatureNew('compiler.get_supported_arguments', '0.43.0') - @permittedKwargs({}) - def get_supported_arguments_method(self, args, kwargs): + @FeatureNewKwargs('compiler.get_supported_arguments', '0.59.0', ['checked']) + @typed_kwargs('compiler.get_supported_arguments', KwargInfo('checked', str, default='off')) + def get_supported_arguments_method(self, args: T.Sequence[str], kwargs: T.Dict[str, T.Any]): args = mesonlib.stringlistify(args) supported_args = [] + checked = kwargs.pop('checked') + + if checked not in ['warn', 'require', 'off']: + raise mesonlib.MesonException('"checked" kwarg must be one of "warn", "require" or "off"') + for arg in args: - if self.has_argument_method(arg, kwargs): + if not self.has_argument_method(arg, kwargs): + msg = f'Compiler for {self.compiler.get_display_language()} does not support "{arg}"' + if checked == 'warn': + mlog.warning(msg) + elif checked == 'require': + raise mesonlib.MesonException(msg) + else: supported_args.append(arg) return supported_args |