Skip to content

Commit 3329b51

Browse files
Qinghao ShiQinghao Shi
authored andcommitted
updates examples
1 parent d91c3d7 commit 3329b51

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

targets/targets.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3751,7 +3751,6 @@
37513751
"device_has": [
37523752
"AACI",
37533753
"ANALOGIN",
3754-
"CLCD",
37553754
"ETHERNET",
37563755
"I2C",
37573756
"INTERRUPTIN",

tools/test/examples/examples.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ def parse_args():
8080
official_target_names, "MCU")),
8181
default=official_target_names)
8282

83-
compile_cmd.add_argument(
84-
"--profiles",
85-
nargs='+',
86-
metavar="profile",
87-
help="build profile(s)")
83+
compile_cmd.add_argument("--profiles",
84+
nargs='+',
85+
metavar="profile",
86+
help="build profile(s)")
8887

8988
compile_cmd.add_argument("-j", "--jobs",
9089
dest='jobs',
@@ -93,6 +92,12 @@ def parse_args():
9392
default=0,
9493
help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
9594

95+
compile_cmd.add_argument("--cmake",
96+
action="store_true",
97+
dest="cmake",
98+
default=False,
99+
help="Use Cmake to build job")
100+
96101
compile_cmd.add_argument("-v", "--verbose",
97102
action="store_true",
98103
dest="verbose",
@@ -159,7 +164,7 @@ def do_deploy(_, config, examples):
159164

160165
def do_compile(args, config, examples):
161166
"""Do the compile step"""
162-
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profiles, args.verbose, examples, args.jobs)
167+
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profiles, args.verbose, examples, args.cmake, args.jobs)
163168
failures = lib.get_build_summary(results)
164169
return failures
165170

tools/test/examples/examples_lib.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def export_repos(config, ides, targets, exp_filter):
329329
return results
330330

331331

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):
333333
"""Compiles combinations of example programs, targets and compile chains.
334334
335335
The results are returned in a [key: value] dictionary format:
@@ -382,22 +382,31 @@ def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, jo
382382
summary_string = "%s %s %s" % (name, target, toolchain)
383383
logging.info("Compiling %s" % summary_string)
384384

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"]
400387
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:
401410
if example['test']:
402411
log = example['compare_log'].pop(0)
403412
# example['compare_log'] is a list of log file/files, which matches each examples/sub-examples from same repo.
@@ -485,6 +494,7 @@ def symlink_mbedos(config, path, exp_filter):
485494
else:
486495
logging.info("Creating Symbolic link '%s'->'mbed-os'" % path)
487496
os.symlink(path, "mbed-os")
497+
open('mbed-os.lib', 'a').close()
488498
os.chdir(CWD)
489499
return 0
490500

0 commit comments

Comments
 (0)