From 8cc6a581624c25ecfea363e226e2714b25722ad3 Mon Sep 17 00:00:00 2001 From: Brian Daniels Date: Tue, 19 Apr 2016 14:14:57 -0500 Subject: [PATCH 1/2] Providing mechainsm for toolchains to exclude a path when scanning for resources --- tools/toolchains/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index 845312b8df..da22533ece 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -341,7 +341,7 @@ class mbedToolchain: return False - def scan_resources(self, path): + def scan_resources(self, path, exclude_path=None): labels = self.get_labels() resources = Resources(path) self.has_config = False @@ -359,12 +359,20 @@ 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_path: + rel_path = relpath(dir_path, exclude_path) + should_exclude_path = not (rel_path.startswith('..')) - 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')): From bbc6e2aba36176f8b8ff061792151dc415f9d936 Mon Sep 17 00:00:00 2001 From: Brian Daniels Date: Wed, 20 Apr 2016 10:56:33 -0500 Subject: [PATCH 2/2] Allowing a list of exclude paths to be passed --- tools/toolchains/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index da22533ece..2236c20737 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -341,7 +341,7 @@ class mbedToolchain: return False - def scan_resources(self, path, exclude_path=None): + def scan_resources(self, path, exclude_paths=None): labels = self.get_labels() resources = Resources(path) self.has_config = False @@ -367,9 +367,12 @@ class mbedToolchain: should_exclude_path = False - if exclude_path: - rel_path = relpath(dir_path, exclude_path) - should_exclude_path = not (rel_path.startswith('..')) + 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 ((should_exclude_path) or (d.startswith('.') or d in self.legacy_ignore_dirs) or