Skip to content

Commit a5aa820

Browse files
authored
Merge pull request #11489 from OPpuolitaival/build_jobs
Examples.py add --jobs argument
2 parents 6790e64 + ff2778f commit a5aa820

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

tools/test/examples/examples.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ def main():
7777
help=("build profile file"),
7878
metavar="profile")
7979

80+
compile_cmd.add_argument("-j", "--jobs",
81+
dest='jobs',
82+
metavar="NUMBER",
83+
type=int,
84+
default=0,
85+
help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
86+
8087
compile_cmd.add_argument("-v", "--verbose",
8188
action="store_true",
8289
dest="verbose",
@@ -136,8 +143,7 @@ def do_deploy(_, config, examples):
136143

137144
def do_compile(args, config, examples):
138145
"""Do the compile step"""
139-
results = {}
140-
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profile, args.verbose, examples)
146+
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profile, args.verbose, examples, args.jobs)
141147
lib.print_summary(results)
142148
failures = lib.get_num_failures(results)
143149
print("Number of failures = %d" % failures)

tools/test/examples/examples_lib.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def status(message):
349349
return results
350350

351351

352-
def compile_repos(config, toolchains, targets, profile, verbose, examples):
352+
def compile_repos(config, toolchains, targets, profile, verbose, examples, jobs=0):
353353
"""Compiles combinations of example programs, targets and compile chains.
354354
355355
The results are returned in a [key: value] dictionary format:
@@ -367,7 +367,11 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples):
367367
Args:
368368
config - the json object imported from the file.
369369
toolchains - List of toolchains to compile for.
370-
results - results of the compilation stage.
370+
targets - list of target names
371+
profile - build profile path or name if in default place
372+
verbose - enabling verbose
373+
examples - List of examples to be build
374+
jobs - Number of compile jobs
371375
372376
"""
373377
results = {}
@@ -398,7 +402,7 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples):
398402
valid_choices(example['toolchains'], toolchains),
399403
example['features']):
400404

401-
build_command = ["mbed-cli", "compile", "-t", toolchain, "-m", target] + (['-vv'] if verbose else [])
405+
build_command = ["mbed-cli", "compile", "-t", toolchain, "-m", target, "-j", str(jobs)] + (['-vv'] if verbose else [])
402406
if profile:
403407
build_command.append("--profile")
404408
build_command.append(profile)

0 commit comments

Comments
 (0)