aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/ast/introspection.py6
-rwxr-xr-xrun_unittests.py4
-rw-r--r--test cases/rewrite/1 basic/addSrc.json5
-rw-r--r--test cases/rewrite/1 basic/info.json5
-rw-r--r--test cases/rewrite/1 basic/meson.build1
-rw-r--r--test cases/rewrite/1 basic/rmSrc.json5
-rw-r--r--test cases/rewrite/1 basic/rmTgt.json5
7 files changed, 29 insertions, 2 deletions
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
index 4a6e6de..7544b60 100644
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -143,7 +143,7 @@ class IntrospectionInterpreter(AstInterpreter):
def build_target(self, node, args, kwargs, targetclass):
args = self.flatten_args(args)
- if not args:
+ if not args or not isinstance(args[0], str):
return
kwargs = self.flatten_kwargs(kwargs, True)
name = args[0]
@@ -166,10 +166,12 @@ class IntrospectionInterpreter(AstInterpreter):
tmp_node = self.assignments[id][0]
if isinstance(tmp_node, (mparser.ArrayNode, mparser.IdNode, mparser.FunctionNode)):
srcqueue += [tmp_node]
+ elif isinstance(curr, mparser.ArithmeticNode):
+ srcqueue += [curr.left, curr.right]
if arg_node is None:
continue
elemetary_nodes = list(filter(lambda x: isinstance(x, (str, mparser.StringNode)), arg_node.arguments))
- srcqueue += list(filter(lambda x: isinstance(x, (mparser.FunctionNode, mparser.ArrayNode, mparser.IdNode)), arg_node.arguments))
+ srcqueue += list(filter(lambda x: isinstance(x, (mparser.FunctionNode, mparser.ArrayNode, mparser.IdNode, mparser.ArithmeticNode)), arg_node.arguments))
# Pop the first element if the function is a build target function
if isinstance(curr, mparser.FunctionNode) and curr.func_name in build_target_functions:
elemetary_nodes.pop(0)
diff --git a/run_unittests.py b/run_unittests.py
index e13903a..b5cb53c 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -5158,6 +5158,7 @@ class RewriterTests(BasePlatformTests):
out = self.extract_test_data(out)
expected = {
'target': {
+ 'trivialprog0@exe': {'name': 'trivialprog0', 'sources': ['main.cpp', 'fileA.cpp', 'fileB.cpp', 'fileC.cpp']},
'trivialprog1@exe': {'name': 'trivialprog1', 'sources': ['main.cpp', 'fileA.cpp']},
'trivialprog2@exe': {'name': 'trivialprog2', 'sources': ['fileB.cpp', 'fileC.cpp']},
'trivialprog3@exe': {'name': 'trivialprog3', 'sources': ['main.cpp', 'fileA.cpp']},
@@ -5177,6 +5178,7 @@ class RewriterTests(BasePlatformTests):
out = self.extract_test_data(out)
expected = {
'target': {
+ 'trivialprog0@exe': {'name': 'trivialprog0', 'sources': ['main.cpp', 'fileA.cpp', 'a1.cpp', 'a2.cpp', 'a6.cpp', 'fileB.cpp', 'fileC.cpp', 'a7.cpp']},
'trivialprog1@exe': {'name': 'trivialprog1', 'sources': ['main.cpp', 'fileA.cpp', 'a1.cpp', 'a2.cpp', 'a6.cpp']},
'trivialprog2@exe': {'name': 'trivialprog2', 'sources': ['fileB.cpp', 'fileC.cpp', 'a7.cpp']},
'trivialprog3@exe': {'name': 'trivialprog3', 'sources': ['main.cpp', 'fileA.cpp', 'a5.cpp']},
@@ -5201,6 +5203,7 @@ class RewriterTests(BasePlatformTests):
out = self.extract_test_data(out)
expected = {
'target': {
+ 'trivialprog0@exe': {'name': 'trivialprog0', 'sources': ['main.cpp', 'fileC.cpp']},
'trivialprog1@exe': {'name': 'trivialprog1', 'sources': ['main.cpp']},
'trivialprog2@exe': {'name': 'trivialprog2', 'sources': ['fileC.cpp']},
'trivialprog3@exe': {'name': 'trivialprog3', 'sources': ['main.cpp']},
@@ -5258,6 +5261,7 @@ class RewriterTests(BasePlatformTests):
expected = {
'target': {
+ 'trivialprog0@exe': {'name': 'trivialprog0', 'sources': ['main.cpp', 'fileA.cpp', 'fileB.cpp', 'fileC.cpp']},
'trivialprog1@exe': {'name': 'trivialprog1', 'sources': ['main.cpp', 'fileA.cpp']},
'trivialprog2@exe': {'name': 'trivialprog2', 'sources': ['fileB.cpp', 'fileC.cpp']},
'trivialprog3@exe': {'name': 'trivialprog3', 'sources': ['main.cpp', 'fileA.cpp']},
diff --git a/test cases/rewrite/1 basic/addSrc.json b/test cases/rewrite/1 basic/addSrc.json
index 7b6144a..1a8630f 100644
--- a/test cases/rewrite/1 basic/addSrc.json
+++ b/test cases/rewrite/1 basic/addSrc.json
@@ -43,6 +43,11 @@
},
{
"type": "target",
+ "target": "trivialprog0",
+ "operation": "info"
+ },
+ {
+ "type": "target",
"target": "trivialprog1",
"operation": "info"
},
diff --git a/test cases/rewrite/1 basic/info.json b/test cases/rewrite/1 basic/info.json
index 7e44bec..0f1a3bd 100644
--- a/test cases/rewrite/1 basic/info.json
+++ b/test cases/rewrite/1 basic/info.json
@@ -1,6 +1,11 @@
[
{
"type": "target",
+ "target": "trivialprog0",
+ "operation": "info"
+ },
+ {
+ "type": "target",
"target": "trivialprog1",
"operation": "info"
},
diff --git a/test cases/rewrite/1 basic/meson.build b/test cases/rewrite/1 basic/meson.build
index 920553d..0f87c45 100644
--- a/test cases/rewrite/1 basic/meson.build
+++ b/test cases/rewrite/1 basic/meson.build
@@ -7,6 +7,7 @@ src4 = [src3]
# Magic comment
+exe0 = executable('trivialprog0', src1 + src2)
exe1 = executable('trivialprog1', src1)
exe2 = executable('trivialprog2', [src2])
exe3 = executable('trivialprog3', ['main.cpp', 'fileA.cpp'])
diff --git a/test cases/rewrite/1 basic/rmSrc.json b/test cases/rewrite/1 basic/rmSrc.json
index 86880a9..2e7447c 100644
--- a/test cases/rewrite/1 basic/rmSrc.json
+++ b/test cases/rewrite/1 basic/rmSrc.json
@@ -37,6 +37,11 @@
},
{
"type": "target",
+ "target": "trivialprog0",
+ "operation": "info"
+ },
+ {
+ "type": "target",
"target": "trivialprog1",
"operation": "info"
},
diff --git a/test cases/rewrite/1 basic/rmTgt.json b/test cases/rewrite/1 basic/rmTgt.json
index ac3f3a2..5774157 100644
--- a/test cases/rewrite/1 basic/rmTgt.json
+++ b/test cases/rewrite/1 basic/rmTgt.json
@@ -1,6 +1,11 @@
[
{
"type": "target",
+ "target": "exe0",
+ "operation": "tgt_rm"
+ },
+ {
+ "type": "target",
"target": "trivialprog1",
"operation": "tgt_rm"
},