Skip to content

Commit fb5c4a6

Browse files
committed
Fixed double-ignored files that cause python exception
Also simplify build scanning logic and add comments
1 parent a07a118 commit fb5c4a6

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

tools/toolchains/__init__.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def __str__(self):
210210

211211
class mbedToolchain:
212212
VERBOSE = True
213-
ignorepatterns = []
213+
ignore_ptrs = []
214214

215215
CORTEX_SYMBOLS = {
216216
"Cortex-M0" : ["__CORTEX_M0", "ARM_MATH_CM0", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
@@ -407,7 +407,7 @@ def need_update(self, target, dependencies):
407407
return False
408408

409409
def is_ignored(self, file_path):
410-
for pattern in self.ignorepatterns:
410+
for pattern in self.ignore_ptrs:
411411
if fnmatch.fnmatch(file_path, pattern):
412412
return True
413413
return False
@@ -441,33 +441,30 @@ def scan_resources(self, path, exclude_paths=None, base_path=None):
441441
lines = [l.strip() for l in lines] # Strip whitespaces
442442
lines = [l for l in lines if l != ""] # Strip empty lines
443443
lines = [l for l in lines if not re.match("^#",l)] # Strip comment lines
444-
# Append root path to glob patterns
445-
# and append patterns to ignorepatterns
446-
self.ignorepatterns.extend([join(root,line.strip()) for line in lines])
444+
# Append root path to glob patterns and append patterns to ignore_ptrs
445+
self.ignore_ptrs.extend([join(root,line.strip()) for line in lines])
447446

448447
for d in copy(dirs):
449448
dir_path = join(root, d)
450449
if d == '.hg':
451450
resources.repo_dirs.append(dir_path)
452451
resources.repo_files.extend(self.scan_repository(dir_path))
453-
452+
454453
if ((d.startswith('.') or d in self.legacy_ignore_dirs) or
454+
# Ignore targets that do not match the TARGET in extra_labels list
455455
(d.startswith('TARGET_') and d[7:] not in labels['TARGET']) or
456+
# Ignore toolchain that do not match the current TOOLCHAIN
456457
(d.startswith('TOOLCHAIN_') and d[10:] not in labels['TOOLCHAIN']) or
458+
# Ignore .mbedignore files
459+
self.is_ignored(join(dir_path,"")) or
460+
# Ignore TESTS dir
457461
(d == 'TESTS')):
458462
dirs.remove(d)
459-
460-
if (d.startswith('FEATURE_')):
463+
elif d.startswith('FEATURE_'):
464+
# Recursively scan features but ignore them in the current scan. These are dynamically added by the config system if the conditions are matched
461465
resources.features[d[8:]] = self.scan_resources(dir_path, base_path=base_path)
462466
dirs.remove(d)
463-
464-
# Remove dirs that already match the ignorepatterns
465-
# to avoid travelling into them and to prevent them
466-
# on appearing in include path.
467-
if self.is_ignored(join(dir_path,"")):
468-
dirs.remove(d)
469-
470-
if exclude_paths:
467+
elif exclude_paths:
471468
for exclude_path in exclude_paths:
472469
rel_path = relpath(dir_path, exclude_path)
473470
if not (rel_path.startswith('..')):

0 commit comments

Comments
 (0)