Skip to content

Commit e835c48

Browse files
committed
Rename ignore_ptrs to ignore_patterns
Add comments to code
1 parent fb5c4a6 commit e835c48

File tree

1 file changed

+48
-31
lines changed

1 file changed

+48
-31
lines changed

tools/toolchains/__init__.py

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

211211
class mbedToolchain:
212212
VERBOSE = True
213-
ignore_ptrs = []
214213

215214
CORTEX_SYMBOLS = {
216215
"Cortex-M0" : ["__CORTEX_M0", "ARM_MATH_CM0", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
@@ -230,48 +229,70 @@ class mbedToolchain:
230229
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
231230
self.target = target
232231
self.name = self.__class__.__name__
232+
233+
# compile/assemble/link/binary hooks
233234
self.hook = hooks.Hook(target, self)
234-
self.silent = silent
235-
self.output = ""
236-
237-
self.legacy_ignore_dirs = LEGACY_IGNORE_DIRS - set([target.name, LEGACY_TOOLCHAIN_NAMES[self.name]])
238-
239-
if notify:
240-
self.notify_fun = notify
241-
elif extra_verbose:
242-
self.notify_fun = self.print_notify_verbose
243-
else:
244-
self.notify_fun = self.print_notify
245235

236+
# Build options passed by -o flag
246237
self.options = options if options is not None else []
247-
248-
self.macros = macros or []
249238
self.options.extend(BUILD_OPTIONS)
250239
if self.options:
251240
self.info("Build Options: %s" % (', '.join(self.options)))
252241

253-
self.obj_path = join("TARGET_"+target.name, "TOOLCHAIN_"+self.name)
254-
242+
# Toolchain flags
243+
self.flags = deepcopy(self.DEFAULT_FLAGS)
244+
245+
# User-defined macros
246+
self.macros = macros or []
247+
248+
# Macros generated from toolchain and target rules/features
255249
self.symbols = None
250+
251+
# Labels generated from toolchain and target rules/features (used for selective build)
256252
self.labels = None
253+
257254
self.has_config = False
255+
# config_header_content will hold the content of the config header (if used)
256+
self.config_header_content = None
258257

258+
# Non-incremental compile
259259
self.build_all = False
260+
261+
# Build output dir
260262
self.build_dir = None
261263
self.timestamp = time()
262-
self.jobs = 1
263264

264-
self.CHROOT = None
265+
# Output build naming based on target+toolchain combo (mbed 2.0 builds)
266+
self.obj_path = join("TARGET_"+target.name, "TOOLCHAIN_"+self.name)
267+
268+
# Number of concurrent build jobs. 0 means auto (based on host system cores)
269+
self.jobs = 0
265270

266-
self.mp_pool = None
271+
self.CHROOT = None
272+
273+
# Ignore patterns from .mbedignore files
274+
self.ignore_patterns = []
275+
276+
# Pre-mbed 2.0 ignore dirs
277+
self.legacy_ignore_dirs = LEGACY_IGNORE_DIRS - set([target.name, LEGACY_TOOLCHAIN_NAMES[self.name]])
267278

279+
# Output notify function
280+
if notify:
281+
self.notify_fun = notify
282+
elif extra_verbose:
283+
self.notify_fun = self.print_notify_verbose
284+
else:
285+
self.notify_fun = self.print_notify
286+
287+
# Silent builds (no output)
288+
self.silent = silent
289+
290+
# Print output buffer
291+
self.output = ""
292+
293+
# uVisor spepcific rules
268294
if 'UVISOR' in self.target.features and 'UVISOR_SUPPORTED' in self.target.extra_labels:
269295
self.target.core = re.sub(r"F$", '', self.target.core)
270-
271-
self.flags = deepcopy(self.DEFAULT_FLAGS)
272-
273-
# config_header_content will hold the content of the config header (if used)
274-
self.config_header_content = None
275296

276297
def get_output(self):
277298
return self.output
@@ -325,10 +346,6 @@ def notify(self, event):
325346
"""
326347
return self.notify_fun(event, self.silent)
327348

328-
def __exit__(self):
329-
if self.mp_pool is not None:
330-
self.mp_pool.terminate()
331-
332349
def goanna_parse_line(self, line):
333350
if "analyze" in self.options:
334351
return self.GOANNA_DIAGNOSTIC_PATTERN.match(line)
@@ -407,7 +424,7 @@ def need_update(self, target, dependencies):
407424
return False
408425

409426
def is_ignored(self, file_path):
410-
for pattern in self.ignore_ptrs:
427+
for pattern in self.ignore_patterns:
411428
if fnmatch.fnmatch(file_path, pattern):
412429
return True
413430
return False
@@ -441,8 +458,8 @@ def scan_resources(self, path, exclude_paths=None, base_path=None):
441458
lines = [l.strip() for l in lines] # Strip whitespaces
442459
lines = [l for l in lines if l != ""] # Strip empty lines
443460
lines = [l for l in lines if not re.match("^#",l)] # Strip comment 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])
461+
# Append root path to glob patterns and append patterns to ignore_patterns
462+
self.ignore_patterns.extend([join(root,line.strip()) for line in lines])
446463

447464
for d in copy(dirs):
448465
dir_path = join(root, d)

0 commit comments

Comments
 (0)