diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2021-02-25 11:29:55 +0000 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2021-02-26 10:15:17 -0500 |
commit | ace22f21a7f0abe9250e673a258e4adf3afa4ac0 (patch) | |
tree | 51ed52296025fc51125e41acabe2eb74d8dd5cc3 /mesonbuild | |
parent | c5aee36fa244287d1a840953a62dc2727037952c (diff) | |
download | meson-ace22f21a7f0abe9250e673a258e4adf3afa4ac0.zip meson-ace22f21a7f0abe9250e673a258e4adf3afa4ac0.tar.gz meson-ace22f21a7f0abe9250e673a258e4adf3afa4ac0.tar.bz2 |
meson: add .has_external_property() methods
Useful in case of boolean values to distinguish between a boolean
value having been set in the native/cross file and not having been
provided, which can't be achieved by passing a fallback parameter
to .get_external_property().
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreter.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 336613f..03e2d4f 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -32,6 +32,7 @@ from .interpreterbase import InterpreterObject, MutableInterpreterObject, Disabl from .interpreterbase import FeatureNew, FeatureDeprecated, FeatureNewKwargs, FeatureDeprecatedKwargs from .interpreterbase import ObjectHolder, MesonVersionString from .interpreterbase import TYPE_var, TYPE_nkwargs +from .interpreterbase import typed_pos_args from .modules import ModuleReturnValue, ExtensionModule from .cmake import CMakeInterpreter from .backend.backends import TestProtocol, Backend, ExecutableSerialisation @@ -1947,6 +1948,7 @@ class MesonMain(InterpreterObject): 'project_name': self.project_name_method, 'get_cross_property': self.get_cross_property_method, 'get_external_property': self.get_external_property_method, + 'has_external_property': self.has_external_property_method, 'backend': self.backend_method, }) @@ -2285,6 +2287,14 @@ class MesonMain(InterpreterObject): else: return _get_native() + @permittedKwargs({'native'}) + @FeatureNew('meson.has_external_property', '0.58.0') + @typed_pos_args('meson.has_external_property', str) + def has_external_property_method(self, args: T.Tuple[str], kwargs: T.Dict[str, T.Any]) -> str: + prop_name = args[0] + for_machine = self.interpreter.machine_from_native_kwarg(kwargs) + return prop_name in self.interpreter.environment.properties[for_machine] + known_library_kwargs = ( build.known_shlib_kwargs | build.known_stlib_kwargs |