aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/ast/interpreter.py24
-rw-r--r--mesonbuild/ast/introspection.py4
-rw-r--r--test cases/unit/55 introspection/meson.build7
-rw-r--r--test cases/unit/55 introspection/meson_options.txt1
4 files changed, 34 insertions, 2 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py
index 01277f0..f1602c0 100644
--- a/mesonbuild/ast/interpreter.py
+++ b/mesonbuild/ast/interpreter.py
@@ -153,8 +153,20 @@ class AstInterpreter(interpreterbase.InterpreterBase):
return True
def evaluate_arithmeticstatement(self, cur):
+ self.evaluate_statement(cur.left)
+ self.evaluate_statement(cur.right)
return 0
+ def evaluate_uminusstatement(self, cur):
+ self.evaluate_statement(cur.value)
+ return 0
+
+ def evaluate_ternary(self, node):
+ assert(isinstance(node, mparser.TernaryNode))
+ self.evaluate_statement(node.condition)
+ self.evaluate_statement(node.trueblock)
+ self.evaluate_statement(node.falseblock)
+
def evaluate_plusassign(self, node):
assert(isinstance(node, mparser.PlusAssignmentNode))
if node.var_name not in self.assignments:
@@ -177,6 +189,18 @@ class AstInterpreter(interpreterbase.InterpreterBase):
return args.arguments, args.kwargs
def evaluate_comparison(self, node):
+ self.evaluate_statement(node.left)
+ self.evaluate_statement(node.right)
+ return False
+
+ def evaluate_andstatement(self, cur):
+ self.evaluate_statement(cur.left)
+ self.evaluate_statement(cur.right)
+ return False
+
+ def evaluate_orstatement(self, cur):
+ self.evaluate_statement(cur.left)
+ self.evaluate_statement(cur.right)
return False
def evaluate_foreach(self, node):
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
index fd7b412..5a12e29 100644
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -20,7 +20,7 @@ from .. import compilers, environment, mesonlib, optinterpreter
from .. import coredata as cdata
from ..interpreterbase import InvalidArguments
from ..build import Executable, Jar, SharedLibrary, SharedModule, StaticLibrary
-from ..mparser import ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode
+from ..mparser import BaseNode, ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode
import os
build_target_functions = ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries']
@@ -191,6 +191,8 @@ class IntrospectionInterpreter(AstInterpreter):
# Make sure nothing can crash when creating the build class
kwargs_reduced = {k: v for k, v in kwargs.items() if k in targetclass.known_kwargs and k in ['install', 'build_by_default', 'build_always']}
+ kwargs_reduced = {k: v.value if isinstance(v, ElementaryNode) else v for k, v in kwargs_reduced.items()}
+ kwargs_reduced = {k: v for k, v in kwargs_reduced.items() if not isinstance(v, BaseNode)}
is_cross = False
objects = []
empty_sources = [] # Passing the unresolved sources list causes errors
diff --git a/test cases/unit/55 introspection/meson.build b/test cases/unit/55 introspection/meson.build
index 15eb1ed..588f71c 100644
--- a/test cases/unit/55 introspection/meson.build
+++ b/test cases/unit/55 introspection/meson.build
@@ -4,6 +4,11 @@ dep1 = dependency('threads')
dep2 = dependency('zlib', required: false)
dep3 = dependency('bugDep1', required: get_option('test_opt1'))
+b1 = get_option('test_opt1')
+b2 = get_option('test_opt2')
+test_bool = b1 or b2
+test_bool = b1 and b2
+
if false
dependency('somethingthatdoesnotexist', required: true)
dependency('look_i_have_a_fallback', fallback: ['oh_no', 'the_subproject_does_not_exist'])
@@ -12,7 +17,7 @@ endif
subdir('sharedlib')
subdir('staticlib')
-t1 = executable('test1', 't1.cpp', link_with: [sharedlib], install: true)
+t1 = executable('test1', 't1.cpp', link_with: [sharedlib], install: true, build_by_default: get_option('test_opt2'))
t2 = executable('test2', 't2.cpp', link_with: [staticlib])
t3 = executable('test3', 't3.cpp', link_with: [sharedlib, staticlib], dependencies: [dep1])
diff --git a/test cases/unit/55 introspection/meson_options.txt b/test cases/unit/55 introspection/meson_options.txt
index b2956c8..fc5cb4d 100644
--- a/test cases/unit/55 introspection/meson_options.txt
+++ b/test cases/unit/55 introspection/meson_options.txt
@@ -1 +1,2 @@
option('test_opt1', type: 'boolean', value: false, description: 'simple boolean flag')
+option('test_opt2', type: 'boolean', value: true, description: 'simple boolean flag')