rewriter: Avoid duplicates

pull/5012/head
Daniel Mensinger 6 years ago committed by Jussi Pakkanen
parent 841da29d2c
commit 7199cd2095
  1. 12
      mesonbuild/rewriter.py
  2. 4
      test cases/rewrite/1 basic/addSrc.json

@ -573,9 +573,19 @@ class Rewriter:
node = target['node']
assert(node is not None)
# Generate the current source list
src_list = []
for i in target['sources']:
for j in arg_list_from_node(i):
if isinstance(j, StringNode):
src_list += [j.value]
# Generate the new String nodes
to_append = []
for i in cmd['sources']:
for i in sorted(set(cmd['sources'])):
if i in src_list:
mlog.log(' -- Source', mlog.green(i), 'is already defined for the target --> skipping')
continue
mlog.log(' -- Adding source', mlog.green(i), 'at',
mlog.yellow('{}:{}'.format(os.path.join(node.subdir, environment.build_filename), node.lineno)))
token = Token('string', node.subdir, 0, 0, 0, None, i)

@ -3,7 +3,7 @@
"type": "target",
"target": "trivialprog1",
"operation": "src_add",
"sources": ["a1.cpp", "a2.cpp"]
"sources": ["a1.cpp", "a2.cpp", "a1.cpp"]
},
{
"type": "target",
@ -39,7 +39,7 @@
"type": "target",
"target": "trivialprog9",
"operation": "src_add",
"sources": ["a6.cpp"]
"sources": ["a6.cpp", "a1.cpp"]
},
{
"type": "target",

Loading…
Cancel
Save