Skip to content

Tools: Omit include path parents when they're scan rules #7623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions tools/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def __init__(self, notify, collect_ignores=False):
# Incremental scan related
self._label_paths = []
self._labels = {"TARGET": [], "TOOLCHAIN": [], "FEATURE": []}
self._prefixed_labels = set()

# Path seperator style (defaults to OS-specific seperator)
self._sep = sep
Expand Down Expand Up @@ -217,12 +218,12 @@ def __str__(self):

def _add_labels(self, prefix, labels):
self._labels[prefix].extend(labels)
prefixed_labels = set("%s_%s" % (prefix, label) for label in labels)
self._prefixed_labels |= set("%s_%s" % (prefix, label) for label in labels)
for path, base_path, into_path in self._label_paths:
if basename(path) in prefixed_labels:
if basename(path) in self._prefixed_labels:
self.add_directory(path, base_path, into_path)
self._label_paths = [(p, b, i) for p, b, i in self._label_paths
if basename(p) not in prefixed_labels]
if basename(p) not in self._prefixed_labels]

def add_target_labels(self, target):
self._add_labels("TARGET", target.labels)
Expand Down Expand Up @@ -276,7 +277,11 @@ def get_file_refs(self, file_type):
def _all_parents(self, files):
for name in files:
components = name.split(self._sep)
start_at = 2 if components[0] == '' else 1
start_at = 2 if components[0] in set(['', '.']) else 1
for index, directory in reversed(list(enumerate(components))[start_at:]):
if directory in self._prefixed_labels:
start_at = index + 1
break
for n in range(start_at, len(components)):
parent = self._sep.join(components[:n])
yield parent
Expand Down