rewriter: Handle Arithmetic node

pull/5018/head
Daniel Mensinger 6 years ago committed by Jussi Pakkanen
parent 1997ac2478
commit bd5d54513c
  1. 6
      mesonbuild/ast/introspection.py
  2. 4
      run_unittests.py
  3. 5
      test cases/rewrite/1 basic/addSrc.json
  4. 5
      test cases/rewrite/1 basic/info.json
  5. 1
      test cases/rewrite/1 basic/meson.build
  6. 5
      test cases/rewrite/1 basic/rmSrc.json
  7. 5
      test cases/rewrite/1 basic/rmTgt.json

@ -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)

@ -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']},

@ -41,6 +41,11 @@
"operation": "src_add",
"sources": ["a6.cpp", "a1.cpp"]
},
{
"type": "target",
"target": "trivialprog0",
"operation": "info"
},
{
"type": "target",
"target": "trivialprog1",

@ -1,4 +1,9 @@
[
{
"type": "target",
"target": "trivialprog0",
"operation": "info"
},
{
"type": "target",
"target": "trivialprog1",

@ -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'])

@ -35,6 +35,11 @@
"operation": "src_rm",
"sources": ["fileB.cpp"]
},
{
"type": "target",
"target": "trivialprog0",
"operation": "info"
},
{
"type": "target",
"target": "trivialprog1",

@ -1,4 +1,9 @@
[
{
"type": "target",
"target": "exe0",
"operation": "tgt_rm"
},
{
"type": "target",
"target": "trivialprog1",

Loading…
Cancel
Save