Skip to content

Fixed double-ignored files that cause python exception #1967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 57 additions & 43 deletions tools/toolchains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def __str__(self):

class mbedToolchain:
VERBOSE = True
ignorepatterns = []

CORTEX_SYMBOLS = {
"Cortex-M0" : ["__CORTEX_M0", "ARM_MATH_CM0", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
Expand All @@ -230,48 +229,70 @@ class mbedToolchain:
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
self.target = target
self.name = self.__class__.__name__

# compile/assemble/link/binary hooks
self.hook = hooks.Hook(target, self)
self.silent = silent
self.output = ""

self.legacy_ignore_dirs = LEGACY_IGNORE_DIRS - set([target.name, LEGACY_TOOLCHAIN_NAMES[self.name]])

if notify:
self.notify_fun = notify
elif extra_verbose:
self.notify_fun = self.print_notify_verbose
else:
self.notify_fun = self.print_notify

# Build options passed by -o flag
self.options = options if options is not None else []

self.macros = macros or []
self.options.extend(BUILD_OPTIONS)
if self.options:
self.info("Build Options: %s" % (', '.join(self.options)))

self.obj_path = join("TARGET_"+target.name, "TOOLCHAIN_"+self.name)

# Toolchain flags
self.flags = deepcopy(self.DEFAULT_FLAGS)

# User-defined macros
self.macros = macros or []

# Macros generated from toolchain and target rules/features
self.symbols = None

# Labels generated from toolchain and target rules/features (used for selective build)
self.labels = None

self.has_config = False
# config_header_content will hold the content of the config header (if used)
self.config_header_content = None

# Non-incremental compile
self.build_all = False

# Build output dir
self.build_dir = None
self.timestamp = time()
self.jobs = 1

self.CHROOT = None
# Output build naming based on target+toolchain combo (mbed 2.0 builds)
self.obj_path = join("TARGET_"+target.name, "TOOLCHAIN_"+self.name)

# Number of concurrent build jobs. 0 means auto (based on host system cores)
self.jobs = 0

self.mp_pool = None
self.CHROOT = None

# Ignore patterns from .mbedignore files
self.ignore_patterns = []

# Pre-mbed 2.0 ignore dirs
self.legacy_ignore_dirs = LEGACY_IGNORE_DIRS - set([target.name, LEGACY_TOOLCHAIN_NAMES[self.name]])

# Output notify function
if notify:
self.notify_fun = notify
elif extra_verbose:
self.notify_fun = self.print_notify_verbose
else:
self.notify_fun = self.print_notify

# Silent builds (no output)
self.silent = silent

# Print output buffer
self.output = ""

# uVisor spepcific rules
if 'UVISOR' in self.target.features and 'UVISOR_SUPPORTED' in self.target.extra_labels:
self.target.core = re.sub(r"F$", '', self.target.core)

self.flags = deepcopy(self.DEFAULT_FLAGS)

# config_header_content will hold the content of the config header (if used)
self.config_header_content = None

def get_output(self):
return self.output
Expand Down Expand Up @@ -325,10 +346,6 @@ def notify(self, event):
"""
return self.notify_fun(event, self.silent)

def __exit__(self):
if self.mp_pool is not None:
self.mp_pool.terminate()

def goanna_parse_line(self, line):
if "analyze" in self.options:
return self.GOANNA_DIAGNOSTIC_PATTERN.match(line)
Expand Down Expand Up @@ -407,7 +424,7 @@ def need_update(self, target, dependencies):
return False

def is_ignored(self, file_path):
for pattern in self.ignorepatterns:
for pattern in self.ignore_patterns:
if fnmatch.fnmatch(file_path, pattern):
return True
return False
Expand Down Expand Up @@ -441,33 +458,30 @@ def scan_resources(self, path, exclude_paths=None, base_path=None):
lines = [l.strip() for l in lines] # Strip whitespaces
lines = [l for l in lines if l != ""] # Strip empty lines
lines = [l for l in lines if not re.match("^#",l)] # Strip comment lines
# Append root path to glob patterns
# and append patterns to ignorepatterns
self.ignorepatterns.extend([join(root,line.strip()) for line in lines])
# Append root path to glob patterns and append patterns to ignore_patterns
self.ignore_patterns.extend([join(root,line.strip()) for line in lines])

for d in copy(dirs):
dir_path = join(root, d)
if d == '.hg':
resources.repo_dirs.append(dir_path)
resources.repo_files.extend(self.scan_repository(dir_path))

if ((d.startswith('.') or d in self.legacy_ignore_dirs) or
# Ignore targets that do not match the TARGET in extra_labels list
(d.startswith('TARGET_') and d[7:] not in labels['TARGET']) or
# Ignore toolchain that do not match the current TOOLCHAIN
(d.startswith('TOOLCHAIN_') and d[10:] not in labels['TOOLCHAIN']) or
# Ignore .mbedignore files
self.is_ignored(join(dir_path,"")) or
# Ignore TESTS dir
(d == 'TESTS')):
dirs.remove(d)

if (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
resources.features[d[8:]] = self.scan_resources(dir_path, base_path=base_path)
dirs.remove(d)

# Remove dirs that already match the ignorepatterns
# to avoid travelling into them and to prevent them
# on appearing in include path.
if self.is_ignored(join(dir_path,"")):
dirs.remove(d)

if exclude_paths:
elif exclude_paths:
for exclude_path in exclude_paths:
rel_path = relpath(dir_path, exclude_path)
if not (rel_path.startswith('..')):
Expand Down