Merge pull request #58 from bridadan/allow-toolchain-exclude-path

Allow toolchains to exclude a path when scan for resources
Bogdan Marinescu 2016-04-25 18:14:28 +03:00
commit 22e1e9837c
1 changed files with 14 additions and 3 deletions

View File

@ -341,7 +341,7 @@ class mbedToolchain:
return False
def scan_resources(self, path):
def scan_resources(self, path, exclude_paths=None):
labels = self.get_labels()
resources = Resources(path)
self.has_config = False
@ -359,12 +359,23 @@ class mbedToolchain:
for root, dirs, files in walk(path):
# Remove ignored directories
for d in copy(dirs):
dir_path = join(root, d)
if d == '.hg':
dir_path = join(root, d)
resources.repo_dirs.append(dir_path)
resources.repo_files.extend(self.scan_repository(dir_path))
should_exclude_path = False
if exclude_paths:
for exclude_path in exclude_paths:
rel_path = relpath(dir_path, exclude_path)
if not (rel_path.startswith('..')):
should_exclude_path = True
break
if ((d.startswith('.') or d in self.legacy_ignore_dirs) or
if ((should_exclude_path) or
(d.startswith('.') or d in self.legacy_ignore_dirs) or
(d.startswith('TARGET_') and d[7:] not in labels['TARGET']) or
(d.startswith('TOOLCHAIN_') and d[10:] not in labels['TOOLCHAIN']) or
(d == 'TESTS')):