@@ -210,7 +210,6 @@ def __str__(self):
210
210
211
211
class mbedToolchain:
212
212
VERBOSE = True
213
- ignorepatterns = []
214
213
215
214
CORTEX_SYMBOLS = {
216
215
"Cortex-M0" : ["__CORTEX_M0", "ARM_MATH_CM0", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
@@ -230,48 +229,70 @@ class mbedToolchain:
230
229
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
231
230
self.target = target
232
231
self.name = self.__class__.__name__
232
+
233
+ # compile/assemble/link/binary hooks
233
234
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
245
235
236
+ # Build options passed by -o flag
246
237
self.options = options if options is not None else []
247
-
248
- self.macros = macros or []
249
238
self.options.extend(BUILD_OPTIONS)
250
239
if self.options:
251
240
self.info("Build Options: %s" % (', '.join(self.options)))
252
241
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
255
249
self.symbols = None
250
+
251
+ # Labels generated from toolchain and target rules/features (used for selective build)
256
252
self.labels = None
253
+
257
254
self.has_config = False
255
+ # config_header_content will hold the content of the config header (if used)
256
+ self.config_header_content = None
258
257
258
+ # Non-incremental compile
259
259
self.build_all = False
260
+
261
+ # Build output dir
260
262
self.build_dir = None
261
263
self.timestamp = time()
262
- self.jobs = 1
263
264
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
265
270
266
- self.mp_pool = None
271
+ self.CHROOT = None
267
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]])
278
+
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
268
294
if 'UVISOR' in self.target.features and 'UVISOR_SUPPORTED' in self.target.extra_labels:
269
295
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
275
296
276
297
def get_output(self):
277
298
return self.output
@@ -325,10 +346,6 @@ def notify(self, event):
325
346
"""
326
347
return self.notify_fun(event, self.silent)
327
348
328
- def __exit__(self):
329
- if self.mp_pool is not None:
330
- self.mp_pool.terminate()
331
-
332
349
def goanna_parse_line(self, line):
333
350
if "analyze" in self.options:
334
351
return self.GOANNA_DIAGNOSTIC_PATTERN.match(line)
@@ -407,7 +424,7 @@ def need_update(self, target, dependencies):
407
424
return False
408
425
409
426
def is_ignored(self, file_path):
410
- for pattern in self.ignorepatterns :
427
+ for pattern in self.ignore_patterns :
411
428
if fnmatch.fnmatch(file_path, pattern):
412
429
return True
413
430
return False
@@ -441,33 +458,30 @@ def scan_resources(self, path, exclude_paths=None, base_path=None):
441
458
lines = [l.strip() for l in lines] # Strip whitespaces
442
459
lines = [l for l in lines if l != ""] # Strip empty lines
443
460
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])
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])
447
463
448
464
for d in copy(dirs):
449
465
dir_path = join(root, d)
450
466
if d == '.hg':
451
467
resources.repo_dirs.append(dir_path)
452
468
resources.repo_files.extend(self.scan_repository(dir_path))
453
-
469
+
454
470
if ((d.startswith('.') or d in self.legacy_ignore_dirs) or
471
+ # Ignore targets that do not match the TARGET in extra_labels list
455
472
(d.startswith('TARGET_') and d[7:] not in labels['TARGET']) or
473
+ # Ignore toolchain that do not match the current TOOLCHAIN
456
474
(d.startswith('TOOLCHAIN_') and d[10:] not in labels['TOOLCHAIN']) or
475
+ # Ignore .mbedignore files
476
+ self.is_ignored(join(dir_path,"")) or
477
+ # Ignore TESTS dir
457
478
(d == 'TESTS')):
458
479
dirs.remove(d)
459
-
460
- if (d.startswith('FEATURE_')):
480
+ elif d.startswith('FEATURE_'):
481
+ # Recursively scan features but ignore them in the current scan. These are dynamically added by the config system if the conditions are matched
461
482
resources.features[d[8:]] = self.scan_resources(dir_path, base_path=base_path)
462
483
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:
484
+ elif exclude_paths:
471
485
for exclude_path in exclude_paths:
472
486
rel_path = relpath(dir_path, exclude_path)
473
487
if not (rel_path.startswith('..')):
0 commit comments