Merge pull request #11489 from OPpuolitaival/build_jobs

Examples.py add --jobs argument
pull/11541/head
Martin Kojtal 2019-09-20 14:13:11 +02:00 committed by GitHub
commit a5aa820f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -77,6 +77,13 @@ def main():
help=("build profile file"),
metavar="profile")
compile_cmd.add_argument("-j", "--jobs",
dest='jobs',
metavar="NUMBER",
type=int,
default=0,
help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
compile_cmd.add_argument("-v", "--verbose",
action="store_true",
dest="verbose",
@ -136,8 +143,7 @@ def do_deploy(_, config, examples):
def do_compile(args, config, examples):
"""Do the compile step"""
results = {}
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profile, args.verbose, examples)
results = lib.compile_repos(config, args.toolchains, args.mcu, args.profile, args.verbose, examples, args.jobs)
lib.print_summary(results)
failures = lib.get_num_failures(results)
print("Number of failures = %d" % failures)

View File

@ -349,7 +349,7 @@ def export_repos(config, ides, targets, examples):
return results
def compile_repos(config, toolchains, targets, profile, verbose, examples):
def compile_repos(config, toolchains, targets, profile, verbose, examples, jobs=0):
"""Compiles combinations of example programs, targets and compile chains.
The results are returned in a [key: value] dictionary format:
@ -367,7 +367,11 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples):
Args:
config - the json object imported from the file.
toolchains - List of toolchains to compile for.
results - results of the compilation stage.
targets - list of target names
profile - build profile path or name if in default place
verbose - enabling verbose
examples - List of examples to be build
jobs - Number of compile jobs
"""
results = {}
@ -398,7 +402,7 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples):
valid_choices(example['toolchains'], toolchains),
example['features']):
build_command = ["mbed-cli", "compile", "-t", toolchain, "-m", target] + (['-vv'] if verbose else [])
build_command = ["mbed-cli", "compile", "-t", toolchain, "-m", target, "-j", str(jobs)] + (['-vv'] if verbose else [])
if profile:
build_command.append("--profile")
build_command.append(profile)