@@ -329,7 +329,7 @@ def export_repos(config, ides, targets, exp_filter):
329
329
return results
330
330
331
331
332
- def compile_repos (config , toolchains , targets , profiles , verbose , exp_filter , jobs = 0 ):
332
+ def compile_repos (config , toolchains , targets , profiles , verbose , exp_filter , cmake = False , jobs = 0 ):
333
333
"""Compiles combinations of example programs, targets and compile chains.
334
334
335
335
The results are returned in a [key: value] dictionary format:
@@ -382,27 +382,36 @@ def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, jo
382
382
summary_string = "%s %s %s" % (name , target , toolchain )
383
383
logging .info ("Compiling %s" % summary_string )
384
384
385
- build_command = ["mbed-cli" , "compile" , "-t" , toolchain , "-m" , target , "-j" , str (jobs )] + (['-vv' ] if verbose else [])
386
- if profiles :
387
- for profile in profiles :
388
- build_command .extend (["--profile" , profile ])
389
-
390
- logging .info ("Executing command '%s'..." % " " .join (build_command ))
391
- proc = subprocess .Popen (build_command , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
392
-
393
- std_out , std_err = proc .communicate ()
394
- std_out = std_out .decode ()
395
- std_err = std_err .decode ()
396
- print ("\n #### STDOUT ####\n %s\n #### STDERR ####\n %s\n #### End of STDOUT/STDERR ####\n " % (std_out ,std_err ))
397
-
398
- if proc .returncode :
399
- failures .append (example_summary )
385
+ if cmake :
386
+ build_command_seq = ["mbed-tools configure -t {} -m {}" .format (toolchain ,target ), "cmake -S . -B CMAKE_BUILD -GNinja" , "cmake --build CMAKE_BUILD" ]
400
387
else :
388
+ build_command_seq = ["mbed-cli compile -t {} -m {} -j {} {}" .format (toolchain , target , str (jobs ), '-vv' if verbose else '' ) ]
389
+ if profiles :
390
+ for profile in profiles :
391
+ build_command_seq [0 ] += " --profile {}" .format (profile )
392
+
393
+ failed_flag = False
394
+ for build_command in build_command_seq :
395
+ logging .info ("Executing command '%s'..." % build_command )
396
+ proc = subprocess .Popen (build_command .split (), stdout = subprocess .PIPE , stderr = subprocess .PIPE )
397
+
398
+ std_out , std_err = proc .communicate ()
399
+ std_out = std_out .decode ()
400
+ std_err = std_err .decode ()
401
+ print ("\n #### STDOUT ####\n %s\n #### STDERR ####\n %s\n #### End of STDOUT/STDERR ####\n " % (std_out ,std_err ))
402
+
403
+ if proc .returncode :
404
+ failures .append (example_summary )
405
+ failed_flag = True
406
+ break
407
+
408
+
409
+ if not failed_flag :
401
410
if example ['test' ]:
402
411
log = example ['compare_log' ].pop (0 )
403
412
# example['compare_log'] is a list of log file/files, which matches each examples/sub-examples from same repo.
404
413
# pop the log file out of list regardless the compilation for each example pass of fail
405
- image = fetch_output_image (std_out )
414
+ image = fetch_output_image (std_out , cmake )
406
415
if image :
407
416
image_info = [{"binary_type" : "bootable" ,"path" : normpath (join (name ,image )),"compare_log" :log }]
408
417
test_group = "{}-{}-{}" .format (target , toolchain , example ['baud_rate' ])
@@ -484,17 +493,25 @@ def symlink_mbedos(config, path, exp_filter):
484
493
else :
485
494
logging .info ("Creating Symbolic link '%s'->'mbed-os'" % path )
486
495
os .symlink (path , "mbed-os" )
496
+ open ('mbed-os.lib' , 'a' ).close ()
487
497
os .chdir (CWD )
488
498
return 0
489
499
490
- def fetch_output_image (output ):
500
+ def fetch_output_image (output , cmake ):
491
501
"""Find the build image from the last 30 lines of a given log"""
492
502
lines = output .splitlines ()
493
503
last_index = - 31 if len (lines )> 29 else (- 1 - len (lines ))
494
504
for index in range (- 1 ,last_index ,- 1 ):
495
- if lines [index ].startswith ("Image:" ):
496
- image = lines [index ][7 :]
497
- if os .path .isfile (image ):
498
- return image
505
+ if cmake :
506
+ if lines [index ].startswith ("-- built:" ) and lines [index ].endswith (".bin" ):
507
+ image = lines [index ][10 :]
508
+ print ("IMAGE is " + image )
509
+ if os .path .isfile (image ):
510
+ return os .path .relpath (image )
511
+ else :
512
+ if lines [index ].startswith ("Image:" ):
513
+ image = lines [index ][7 :]
514
+ if os .path .isfile (image ):
515
+ return image
499
516
return False
500
517
0 commit comments