Skip to content

Commit 0bbac41

Browse files
authored
Merge pull request #1999 from screamerbg/fix-ignore-root
Fixed .mbedignore logic to ignore the walk() root
2 parents 303f39a + 6c53baf commit 0bbac41

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tools/toolchains/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,8 @@ def scan_resources(self, path, exclude_paths=None, base_path=None):
443443
itself is generated.
444444
"""
445445
for root, dirs, files in walk(path, followlinks=True):
446-
# Remove ignored directories
447446
# Check if folder contains .mbedignore
448-
if ".mbedignore" in files :
447+
if ".mbedignore" in files:
449448
with open (join(root,".mbedignore"), "r") as f:
450449
lines=f.readlines()
451450
lines = [l.strip() for l in lines] # Strip whitespaces
@@ -454,8 +453,13 @@ def scan_resources(self, path, exclude_paths=None, base_path=None):
454453
# Append root path to glob patterns and append patterns to ignore_patterns
455454
self.ignore_patterns.extend([join(root,line.strip()) for line in lines])
456455

456+
# Skip the whole folder if ignored, e.g. .mbedignore containing '*'
457+
if self.is_ignored(join(root,"")):
458+
continue
459+
457460
for d in copy(dirs):
458461
dir_path = join(root, d)
462+
# Add internal repo folders/files. This is needed for exporters
459463
if d == '.hg':
460464
resources.repo_dirs.append(dir_path)
461465
resources.repo_files.extend(self.scan_repository(dir_path))
@@ -469,9 +473,10 @@ def scan_resources(self, path, exclude_paths=None, base_path=None):
469473
self.is_ignored(join(dir_path,"")) or
470474
# Ignore TESTS dir
471475
(d == 'TESTS')):
472-
dirs.remove(d)
476+
dirs.remove(d)
473477
elif d.startswith('FEATURE_'):
474-
# Recursively scan features but ignore them in the current scan. These are dynamically added by the config system if the conditions are matched
478+
# Recursively scan features but ignore them in the current scan.
479+
# These are dynamically added by the config system if the conditions are matched
475480
resources.features[d[8:]] = self.scan_resources(dir_path, base_path=base_path)
476481
dirs.remove(d)
477482
elif exclude_paths:

0 commit comments

Comments
 (0)