1
+ #!/usr/bin/env python
2
+
1
3
"""
2
4
Copyright (c) 2017-2019 ARM Limited. All rights reserved.
3
5
53
55
54
56
55
57
def get_build_summary (results ):
56
- """Prints to screen the results of compiling/exporting combinations of example programs,
57
- targets and compile toolchains/IDEs.
58
+ """Prints to screen the complication results of example programs.
58
59
59
60
Args:
60
- results - results of the compilation stage. See compile_repos() and export_repos ()
61
- for details of the format.
62
-
61
+ results - results of the compilation stage. which is the output of compile_repos ()
62
+
63
+ Returns: Numbers of failed results
63
64
"""
64
65
pass_table = PrettyTable ()
65
66
pass_table .field_names = ["EXAMPLE NAME" , "TARGET" , "TOOLCHAIN" , "TEST GEN" , "BUILD RESULT" ]
@@ -82,13 +83,12 @@ def get_build_summary(results):
82
83
return failure_counter
83
84
84
85
def get_export_summary (results ):
85
- """Prints to screen the results of compiling/exporting combinations of example programs,
86
- targets and compile toolchains/IDEs.
86
+ """Prints to screen the exporting results of example programs.
87
87
88
88
Args:
89
- results - results of the compilation stage. See compile_repos() and export_repos()
90
- for details of the format.
91
-
89
+ results - results of the compilation stage. which is the output of and export_repos()
90
+
91
+ Returns: Numbers of failed results
92
92
"""
93
93
pass_table = PrettyTable ()
94
94
pass_table .field_names = ["EXAMPLE NAME" , "TARGET" , "IDE" , "EXPORT RESULT" , "BUILD RESULT" ]
@@ -162,8 +162,7 @@ def target_cross_ide(allowed_targets, allowed_ides, features=[], toolchains=[]):
162
162
163
163
164
164
def get_sub_examples_list (example ):
165
- """
166
- """
165
+ """ Get the names of sub examples. if no sub examples, return the name of main example"""
167
166
sub_examples = []
168
167
if example ['sub-repo-example' ]:
169
168
for sub in example ['subs' ]:
@@ -330,7 +329,7 @@ def export_repos(config, ides, targets, exp_filter):
330
329
return results
331
330
332
331
333
- def compile_repos (config , toolchains , targets , profile , verbose , exp_filter , jobs = 0 ):
332
+ def compile_repos (config , toolchains , targets , profiles , verbose , exp_filter , jobs = 0 ):
334
333
"""Compiles combinations of example programs, targets and compile chains.
335
334
336
335
The results are returned in a [key: value] dictionary format:
@@ -382,19 +381,20 @@ def compile_repos(config, toolchains, targets, profile, verbose, exp_filter, job
382
381
example_summary = {"name" : name , "target" : target , "toolchain" : toolchain , "test" : "UNSET" }
383
382
summary_string = "%s %s %s" % (name , target , toolchain )
384
383
logging .info ("Compiling %s" % summary_string )
385
-
384
+
386
385
build_command = ["mbed-cli" , "compile" , "-t" , toolchain , "-m" , target , "-j" , str (jobs )] + (['-vv' ] if verbose else [])
387
- if profile :
388
- build_command . append ( "-- profile" )
389
- build_command .append ( profile )
390
-
386
+ if profiles :
387
+ for profile in profiles :
388
+ build_command .extend ([ "-- profile" , profile ] )
389
+
391
390
logging .info ("Executing command '%s'..." % " " .join (build_command ))
392
391
proc = subprocess .Popen (build_command , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
393
392
394
393
std_out , std_err = proc .communicate ()
395
- std_out = std_out .decode ('utf-8' )
394
+ std_out = std_out .decode ()
395
+ std_err = std_err .decode ()
396
396
print ("\n #### STDOUT ####\n %s\n #### STDERR ####\n %s\n #### End of STDOUT/STDERR ####\n " % (std_out ,std_err ))
397
-
397
+
398
398
if proc .returncode :
399
399
failures .append (example_summary )
400
400
else :
@@ -465,7 +465,8 @@ def update_mbedos_version(config, tag, exp_filter):
465
465
return 0
466
466
467
467
def symlink_mbedos (config , path , exp_filter ):
468
- """
468
+ """ Create a symbolic link in each example folder to given path
469
+ If a mbed-os.lib can be found in the folder, it will be removed
469
470
"""
470
471
print ("\n Creating mbed-os Symbolic link to '%s'\n " % path )
471
472
for example in config ['examples' ]:
@@ -475,11 +476,15 @@ def symlink_mbedos(config, path, exp_filter):
475
476
os .chdir (name )
476
477
logging .info ("In folder '%s'" % name )
477
478
if os .path .exists ("mbed-os.lib" ):
479
+ logging .info ("Removing 'mbed-os.lib' in '%s'" % name )
478
480
os .remove ("mbed-os.lib" )
479
481
else :
480
482
logging .warning ("No 'mbed-os.lib' found in '%s'" % name )
481
- logging .info ("Creating Symbolic link '%s'->'mbed-os'" % path )
482
- os .symlink (path , "mbed-os" )
483
+ if os .path .exists ("mbed-os" ):
484
+ logging .warning ("'mbed-os' already existed in '%s'" % name )
485
+ else :
486
+ logging .info ("Creating Symbolic link '%s'->'mbed-os'" % path )
487
+ os .symlink (path , "mbed-os" )
483
488
os .chdir (CWD )
484
489
return 0
485
490
@@ -492,4 +497,5 @@ def fetch_output_image(output):
492
497
image = lines [index ][7 :]
493
498
if os .path .isfile (image ):
494
499
return image
495
- return False
500
+ return False
501
+
0 commit comments