Fixed match walk() root against the ignore list.

For example .mbedignore in tools/ contains '*' and naturally should match all files, folders including tools/ itself. Without this fix, tools/ is added to the include path
pull/1999/head
Mihail Stoyanov 2016-06-24 01:20:54 +01:00
parent f864b8439f
commit 6c53baf7d2
1 changed files with 9 additions and 4 deletions

View File

@ -443,7 +443,6 @@ class mbedToolchain:
itself is generated. itself is generated.
""" """
for root, dirs, files in walk(path, followlinks=True): for root, dirs, files in walk(path, followlinks=True):
# Remove ignored directories
# Check if folder contains .mbedignore # Check if folder contains .mbedignore
if ".mbedignore" in files: if ".mbedignore" in files:
with open (join(root,".mbedignore"), "r") as f: with open (join(root,".mbedignore"), "r") as f:
@ -454,8 +453,13 @@ class mbedToolchain:
# Append root path to glob patterns and append patterns to ignore_patterns # Append root path to glob patterns and append patterns to ignore_patterns
self.ignore_patterns.extend([join(root,line.strip()) for line in lines]) self.ignore_patterns.extend([join(root,line.strip()) for line in lines])
# Skip the whole folder if ignored, e.g. .mbedignore containing '*'
if self.is_ignored(join(root,"")):
continue
for d in copy(dirs): for d in copy(dirs):
dir_path = join(root, d) dir_path = join(root, d)
# Add internal repo folders/files. This is needed for exporters
if d == '.hg': if d == '.hg':
resources.repo_dirs.append(dir_path) resources.repo_dirs.append(dir_path)
resources.repo_files.extend(self.scan_repository(dir_path)) resources.repo_files.extend(self.scan_repository(dir_path))
@ -471,7 +475,8 @@ class mbedToolchain:
(d == 'TESTS')): (d == 'TESTS')):
dirs.remove(d) dirs.remove(d)
elif d.startswith('FEATURE_'): elif d.startswith('FEATURE_'):
# Recursively scan features but ignore them in the current scan. These are dynamically added by the config system if the conditions are matched # Recursively scan features but ignore them in the current scan.
# These are dynamically added by the config system if the conditions are matched
resources.features[d[8:]] = self.scan_resources(dir_path, base_path=base_path) resources.features[d[8:]] = self.scan_resources(dir_path, base_path=base_path)
dirs.remove(d) dirs.remove(d)
elif exclude_paths: elif exclude_paths: