aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorJames Hilliard <james.hilliard1@gmail.com>2019-05-26 12:31:43 -0600
committerJussi Pakkanen <jpakkane@gmail.com>2019-08-12 01:05:45 +0300
commitb21fd95f737ab96f57c45e15a1d89d5c483daec8 (patch)
treef19e6f869220b3832d4e586901d10bb059d5a5d8 /mesonbuild
parent8764e4f579287d2bc15d5ea8b0a5382c90712ec0 (diff)
downloadmeson-b21fd95f737ab96f57c45e15a1d89d5c483daec8.zip
meson-b21fd95f737ab96f57c45e15a1d89d5c483daec8.tar.gz
meson-b21fd95f737ab96f57c45e15a1d89d5c483daec8.tar.bz2
Add is_disabler function
This is useful if one needs to check if a variable is a disabler. Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/ast/interpreter.py1
-rw-r--r--mesonbuild/interpreter.py9
-rw-r--r--mesonbuild/interpreterbase.py2
3 files changed, 11 insertions, 1 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py
index 13c717b..6684ca4 100644
--- a/mesonbuild/ast/interpreter.py
+++ b/mesonbuild/ast/interpreter.py
@@ -106,6 +106,7 @@ class AstInterpreter(interpreterbase.InterpreterBase):
'subdir': self.func_subdir,
'set_variable': self.func_do_nothing,
'get_variable': self.func_do_nothing,
+ 'is_disabler': self.func_do_nothing,
'is_variable': self.func_do_nothing,
'disabler': self.func_do_nothing,
'gettext': self.func_do_nothing,
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index d45b313..3a5dfaf 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2147,6 +2147,7 @@ class Interpreter(InterpreterBase):
'install_headers': self.func_install_headers,
'install_man': self.func_install_man,
'install_subdir': self.func_install_subdir,
+ 'is_disabler': self.func_is_disabler,
'is_variable': self.func_is_variable,
'jar': self.func_jar,
'join_paths': self.func_join_paths,
@@ -4278,3 +4279,11 @@ This will become a hard error in the future.''', location=self.current_node)
if not isinstance(native, bool):
raise InvalidArguments('Argument to "native" must be a boolean.')
return MachineChoice.BUILD if native else MachineChoice.HOST
+
+ @FeatureNew('is_disabler', '0.52.0')
+ @noKwargs
+ def func_is_disabler(self, node, args, kwargs):
+ if len(args) != 1:
+ raise InvalidCode('Is_disabler takes one argument.')
+ varname = args[0]
+ return isinstance(varname, Disabler)
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py
index b5510cf..082515c 100644
--- a/mesonbuild/interpreterbase.py
+++ b/mesonbuild/interpreterbase.py
@@ -767,7 +767,7 @@ The result of this is undefined and will become a hard error in a future Meson r
def function_call(self, node):
func_name = node.func_name
(posargs, kwargs) = self.reduce_arguments(node.args)
- if is_disabled(posargs, kwargs):
+ if is_disabled(posargs, kwargs) and func_name != 'set_variable' and func_name != 'is_disabler':
return Disabler()
if func_name in self.funcs:
func = self.funcs[func_name]