2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 01:46:15 +01:00

Prevent duplicates in c_preproc.py results

This commit is contained in:
Thomas Nagy 2017-08-26 12:13:49 +02:00
parent 5b935a1e6a
commit 5c15f6f39e
No known key found for this signature in database
GPG Key ID: 49B4C67C05277AAA
2 changed files with 12 additions and 6 deletions

View File

@ -187,9 +187,9 @@ def build(bld):
disp(color, "%s\t\t%r" % (expected, gruik.nodes))
test_rec("", "a")
test_rec("FOO=1", "aca")
test_rec("BAR=1", "abca")
test_rec("FOO=1 BAR=1", "aca")
test_rec("FOO=1", "ac")
test_rec("BAR=1", "abc")
test_rec("FOO=1 BAR=1", "ac")
return
test("1?1,(0?5:9):3,4", 0) # <- invalid expression

View File

@ -828,6 +828,9 @@ class c_parser(object):
self.ban_includes = set()
"""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):
"""
Find a file from the input directory
@ -888,12 +891,15 @@ class c_parser(object):
break
found = self.cached_find_resource(n, filename)
listed = self.listed
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
self.nodes.append(found)
if found not in listed:
listed.add(found)
self.nodes.append(found)
self.addlines(found)
else:
if not filename in self.names:
if filename not in listed:
listed.add(filename)
self.names.append(filename)
return found