mirror of https://gitlab.com/ita1024/waf.git
Prevent duplicates in c_preproc.py results
This commit is contained in:
parent
5b935a1e6a
commit
5c15f6f39e
|
@ -187,9 +187,9 @@ def build(bld):
|
||||||
disp(color, "%s\t\t%r" % (expected, gruik.nodes))
|
disp(color, "%s\t\t%r" % (expected, gruik.nodes))
|
||||||
|
|
||||||
test_rec("", "a")
|
test_rec("", "a")
|
||||||
test_rec("FOO=1", "aca")
|
test_rec("FOO=1", "ac")
|
||||||
test_rec("BAR=1", "abca")
|
test_rec("BAR=1", "abc")
|
||||||
test_rec("FOO=1 BAR=1", "aca")
|
test_rec("FOO=1 BAR=1", "ac")
|
||||||
|
|
||||||
return
|
return
|
||||||
test("1?1,(0?5:9):3,4", 0) # <- invalid expression
|
test("1?1,(0?5:9):3,4", 0) # <- invalid expression
|
||||||
|
|
|
@ -828,6 +828,9 @@ class c_parser(object):
|
||||||
self.ban_includes = set()
|
self.ban_includes = set()
|
||||||
"""Includes that must not be read (#pragma once)"""
|
"""Includes that must not be read (#pragma once)"""
|
||||||
|
|
||||||
|
self.listed = set()
|
||||||
|
"""Include nodes/names already listed to avoid duplicates in self.nodes/self.names"""
|
||||||
|
|
||||||
def cached_find_resource(self, node, filename):
|
def cached_find_resource(self, node, filename):
|
||||||
"""
|
"""
|
||||||
Find a file from the input directory
|
Find a file from the input directory
|
||||||
|
@ -888,12 +891,15 @@ class c_parser(object):
|
||||||
break
|
break
|
||||||
found = self.cached_find_resource(n, filename)
|
found = self.cached_find_resource(n, filename)
|
||||||
|
|
||||||
|
listed = self.listed
|
||||||
if found and not found in self.ban_includes:
|
if found and not found in self.ban_includes:
|
||||||
# TODO duplicates do not increase the no-op build times too much, but they may be worth removing
|
if found not in listed:
|
||||||
self.nodes.append(found)
|
listed.add(found)
|
||||||
|
self.nodes.append(found)
|
||||||
self.addlines(found)
|
self.addlines(found)
|
||||||
else:
|
else:
|
||||||
if not filename in self.names:
|
if filename not in listed:
|
||||||
|
listed.add(filename)
|
||||||
self.names.append(filename)
|
self.names.append(filename)
|
||||||
return found
|
return found
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue