@@ -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 ), "rm -fr cmake_build" ,"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' ])
@@ -438,7 +447,7 @@ def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, jo
438
447
return results
439
448
440
449
441
- def update_mbedos_version (config , tag , exp_filter ):
450
+ def update_example_version (config , tag , exp_filter ):
442
451
""" For each example repo identified in the config json object, update the version of
443
452
mbed-os to that specified by the supplied GitHub tag. This function assumes that each
444
453
example repo has already been cloned.
@@ -448,15 +457,15 @@ def update_mbedos_version(config, tag, exp_filter):
448
457
tag - GitHub tag corresponding to a version of mbed-os to upgrade to.
449
458
450
459
"""
451
- print ("\n Updating mbed-os in examples to version '%s'\n " % tag )
460
+ print ("\n Updating examples to version(branch) '%s'\n " % tag )
452
461
for example in config ['examples' ]:
453
462
if example ['name' ] not in exp_filter :
454
463
continue
455
464
for name in get_sub_examples_list (example ):
456
465
update_dir = name + "/mbed-os"
457
- os .chdir (update_dir )
466
+ os .chdir (name )
458
467
logging .info ("In folder '%s'" % name )
459
- cmd = "mbed-cli update %s --clean " % tag
468
+ cmd = "git checkout -B %s origin/%s " % ( tag , tag )
460
469
logging .info ("Executing command '%s'..." % cmd )
461
470
result = subprocess .call (cmd , shell = True )
462
471
os .chdir (CWD )
@@ -476,26 +485,34 @@ def symlink_mbedos(config, path, exp_filter):
476
485
os .chdir (name )
477
486
logging .info ("In folder '%s'" % name )
478
487
if os .path .exists ("mbed-os.lib" ):
479
- logging .info ("Removing 'mbed-os.lib' in '%s'" % name )
480
- os . remove ("mbed-os.lib" )
488
+ logging .info ("Replacing 'mbed-os.lib' in '%s'" % name )
489
+ open ("mbed-os.lib" , 'w' ). close ( )
481
490
else :
482
491
logging .warning ("No 'mbed-os.lib' found in '%s'" % name )
483
492
if os .path .exists ("mbed-os" ):
484
493
logging .warning ("'mbed-os' already existed in '%s'" % name )
485
494
else :
486
495
logging .info ("Creating Symbolic link '%s'->'mbed-os'" % path )
487
496
os .symlink (path , "mbed-os" )
497
+ open ('mbed-os.lib' , 'a' ).close ()
488
498
os .chdir (CWD )
489
499
return 0
490
500
491
- def fetch_output_image (output ):
501
+ def fetch_output_image (output , cmake ):
492
502
"""Find the build image from the last 30 lines of a given log"""
493
503
lines = output .splitlines ()
494
504
last_index = - 31 if len (lines )> 29 else (- 1 - len (lines ))
495
505
for index in range (- 1 ,last_index ,- 1 ):
496
- if lines [index ].startswith ("Image:" ):
497
- image = lines [index ][7 :]
498
- if os .path .isfile (image ):
499
- return image
506
+ if cmake :
507
+ if lines [index ].startswith ("-- built:" ) and lines [index ].endswith (".bin" ):
508
+ image = lines [index ][10 :]
509
+ print ("IMAGE is " + image )
510
+ if os .path .isfile (image ):
511
+ return image
512
+ else :
513
+ if lines [index ].startswith ("Image:" ):
514
+ image = lines [index ][7 :]
515
+ if os .path .isfile (image ):
516
+ return image
500
517
return False
501
518
0 commit comments