@@ -316,7 +316,7 @@ def export_repos(config, ides, targets, exp_filter):
316
316
return results
317
317
318
318
319
- def compile_repos (config , toolchains , targets , profile , verbose , examples , jobs = 0 ):
319
+ def compile_repos (config , toolchains , targets , profile , verbose , exp_filter , jobs = 0 ):
320
320
"""Compiles combinations of example programs, targets and compile chains.
321
321
322
322
The results are returned in a [key: value] dictionary format:
@@ -337,68 +337,61 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples, jobs=
337
337
targets - list of target names
338
338
profile - build profile path or name if in default place
339
339
verbose - enabling verbose
340
- examples - List of examples to be build
340
+ exp_filter - List of exp_filter to be build
341
341
jobs - Number of compile jobs
342
342
343
343
"""
344
344
results = {}
345
345
test_json = {"builds" :{}}
346
- valid_examples = set (examples )
347
346
base_path = os .getcwd ()
348
347
print ("\n Compiling example repos....\n " )
349
348
for example in config ['examples' ]:
350
- example_names = [basename (x ['repo' ]) for x in get_repo_list (example )]
351
- common_examples = valid_examples .intersection (set (example_names ))
352
- if not common_examples :
349
+ if example ['name' ] not in exp_filter :
353
350
continue
354
351
failures = []
355
352
successes = []
356
353
compiled = True
357
354
pass_status = True
358
- if 'test' in example and example ['test' ] and 'baud_rate' in example and 'compare_log' in example :
359
- test_example = True
360
- else :
361
- test_example = False
355
+ if example ['test' ]:
356
+ if not ( 'baud_rate' in example and 'compare_log' in example ):
357
+ logging . warning ( "'baud_rate' or 'compare_log' keys are missing from config json file" )
358
+ example [ 'test' ] = False
362
359
if example ['compile' ]:
363
- for repo_info in get_repo_list (example ):
364
- name = basename (repo_info ['repo' ])
360
+ for name in get_sub_examples_list (example ):
365
361
os .chdir (name )
362
+ logging .info ("In folder '%s'" % name )
366
363
# Check that the target, toolchain and features combinations are valid and return a
367
364
# list of valid combinations to work through
368
365
for target , toolchain in target_cross_toolchain (valid_choices (example ['targets' ], targets ),
369
366
valid_choices (example ['toolchains' ], toolchains ),
370
367
example ['features' ]):
368
+ example_summary = {"name" : name , "target" : target , "toolchain" : toolchain , "test" : "UNSET" }
369
+ summary_string = "%s %s %s" % (name , target , toolchain )
370
+ logging .info ("Compiling %s" % summary_string )
371
371
372
372
build_command = ["mbed-cli" , "compile" , "-t" , toolchain , "-m" , target , "-j" , str (jobs )] + (['-vv' ] if verbose else [])
373
373
if profile :
374
374
build_command .append ("--profile" )
375
375
build_command .append (profile )
376
376
377
- print ("Compiling [%s] for [%s] with toolchain [%s]\n \n > %s" % (name , target , toolchain , " " .join (build_command )))
378
-
377
+ logging .info ("Executing command '%s'..." % " " .join (build_command ))
379
378
proc = subprocess .Popen (build_command , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
380
379
381
380
std_out , std_err = proc .communicate ()
382
381
std_out = std_out .decode ('utf-8' )
383
382
print ("\n #### STDOUT ####\n %s\n #### STDERR ####\n %s\n #### End of STDOUT/STDERR ####\n " % (std_out ,std_err ))
384
383
385
- if test_example :
386
- log = example ['compare_log' ].pop (0 )
387
- # example['compare_log'] is a list of log file/files, which matches each examples/sub-examples from same repo.
388
- # pop the log file out of list regardless the compilation for each example pass of fail
389
- image = fetch_output_image (std_out )
390
- if image :
391
- image_info = [{"binary_type" : "bootable" ,"path" : normpath (join (name ,image )),"compare_log" :log }]
392
- else :
393
- print ("Warning: could not find built image for example %s" % name )
394
-
395
- example_summary = "{} {} {}" .format (name , target , toolchain )
396
384
if proc .returncode :
397
385
failures .append (example_summary )
398
386
else :
399
- if test_example :
400
- test_group = "{}-{}-{}" .format (target , toolchain , example ['baud_rate' ])
387
+ if example ['test' ]:
388
+ log = example ['compare_log' ].pop (0 )
389
+ # example['compare_log'] is a list of log file/files, which matches each examples/sub-examples from same repo.
390
+ # pop the log file out of list regardless the compilation for each example pass of fail
391
+ image = fetch_output_image (std_out )
401
392
if image :
393
+ image_info = [{"binary_type" : "bootable" ,"path" : normpath (join (name ,image )),"compare_log" :log }]
394
+ test_group = "{}-{}-{}" .format (target , toolchain , example ['baud_rate' ])
402
395
if not test_group in test_json ['builds' ]:
403
396
test_json ['builds' ][test_group ] = {
404
397
"platform" :target ,
@@ -407,16 +400,17 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples, jobs=
407
400
"baud_rate" : int (example ['baud_rate' ]),
408
401
"tests" :{} }
409
402
test_json ['builds' ][test_group ]['tests' ][name ]= {"binaries" :image_info }
410
- test_status = "TEST_ON"
403
+ example_summary ["test" ] = "TEST_ON"
404
+
411
405
else :
412
- test_status = "NO_IMAGE"
406
+ logging .warning ("could not find built image for example %s" % name )
407
+ example_summary ["test" ] = "NO_IMAGE"
413
408
else :
414
- print ("Warning: Test for %s will not be generated." % name )
415
- print ("One or more of 'test', 'baud_rate', and 'compare_log' keys are missing from the example config json file\n " )
416
- test_status = "TEST_OFF"
417
- successes .append (example_summary + " " + test_status )
409
+ logging .warning ("Test for %s will not be generated." % name )
410
+ example_summary ["test" ] = "TEST_OFF"
411
+ successes .append (example_summary )
418
412
419
- os .chdir (".." )
413
+ os .chdir (CWD )
420
414
421
415
# If there are any compilation failures for the example 'set' then the overall status is fail.
422
416
if len (failures ) > 0 :
@@ -476,9 +470,9 @@ def symlink_mbedos(config, path, exp_filter):
476
470
return 0
477
471
478
472
def fetch_output_image (output ):
479
- """Find the build image from the last 5 lines of a given log"""
473
+ """Find the build image from the last 30 lines of a given log"""
480
474
lines = output .splitlines ()
481
- last_index = - 6 if len (lines )> 4 else (- 1 - len (lines ))
475
+ last_index = - 31 if len (lines )> 29 else (- 1 - len (lines ))
482
476
for index in range (- 1 ,last_index ,- 1 ):
483
477
if lines [index ].startswith ("Image:" ):
484
478
image = lines [index ][7 :]
0 commit comments