mirror of https://github.com/ARMmbed/mbed-os.git
Add boolean 'export' to examples.json.
This will determine whether the example should be exported. Additionally, relocated export logic to examples_lib.py.pull/3172/head
parent
cc154a48cd
commit
9624ccf2d5
|
@ -9,7 +9,9 @@
|
|||
"features" : [],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"exporters": [],
|
||||
"compile" : true,
|
||||
"export": true,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -24,7 +26,9 @@
|
|||
"features" : [],
|
||||
"targets" : ["K64F", "NUCLEO_F429ZI"],
|
||||
"toolchains" : ["GCC_ARM", "ARM"],
|
||||
"exporters": [],
|
||||
"compile" : true,
|
||||
"export": false,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +40,9 @@
|
|||
"features" : ["IPV6"],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"exporters": [],
|
||||
"compile" : true,
|
||||
"export": false,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -57,7 +63,9 @@
|
|||
"features" : ["BLE"],
|
||||
"targets" : ["NRF51_DK", "NRF52_DK", "K64F", "NUCLEO_F401RE"],
|
||||
"toolchains" : [],
|
||||
"exporters": [],
|
||||
"compile" : true,
|
||||
"export": false,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -69,7 +77,9 @@
|
|||
"features" : ["IPV6"],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"exporters": [],
|
||||
"compile" : true,
|
||||
"export": false,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -80,7 +90,9 @@
|
|||
"features" : ["IPV6"],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"exporters": [],
|
||||
"compile" : true,
|
||||
"export": false,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -91,7 +103,9 @@
|
|||
"features" : [],
|
||||
"targets" : [],
|
||||
"toolchains" : [],
|
||||
"exporters": [],
|
||||
"compile" : false,
|
||||
"export": false,
|
||||
"auto-update" : true
|
||||
},
|
||||
{
|
||||
|
@ -102,7 +116,9 @@
|
|||
"features" : [],
|
||||
"targets" : ["K64F"],
|
||||
"toolchains" : ["GCC_ARM"],
|
||||
"exporters": [],
|
||||
"compile" : true,
|
||||
"export": false,
|
||||
"auto-update" : false
|
||||
}
|
||||
]
|
||||
|
|
|
@ -13,70 +13,11 @@ sys.path.insert(0, ROOT)
|
|||
|
||||
from tools.utils import argparse_force_uppercase_type
|
||||
import examples_lib as lib
|
||||
from examples_lib import SUPPORTED_TOOLCHAINS
|
||||
from tools.export import EXPORTERS
|
||||
from tools.build_api import get_mbed_official_release
|
||||
from tools.targets import TARGET_MAP
|
||||
from examples_lib import SUPPORTED_TOOLCHAINS, SUPPORTED_IDES
|
||||
|
||||
EXAMPLES = json.load(open(os.path.join(os.path.dirname(__file__),
|
||||
"examples.json")))
|
||||
|
||||
def print_stuff(name, lst):
|
||||
if lst:
|
||||
print("#"*80)
|
||||
print("# {} example combinations".format(name))
|
||||
print("#")
|
||||
for thing in lst:
|
||||
print(thing)
|
||||
|
||||
|
||||
SUPPORTED_TOOLCHAINS = ["ARM", "IAR", "GCC_ARM"]
|
||||
SUPPORTED_IDES = ["iar", "uvision", "make_gcc_arm", "make_iar", "make_armc5"]
|
||||
|
||||
|
||||
def target_cross_toolchain(allowed_toolchains,
|
||||
features=[], targets=TARGET_MAP.keys(),
|
||||
toolchains=SUPPORTED_TOOLCHAINS):
|
||||
"""Generate pairs of target and toolchains
|
||||
|
||||
Args:
|
||||
allowed_toolchains - a list of all possible toolchains
|
||||
|
||||
Kwargs:
|
||||
features - the features that must be in the features array of a
|
||||
target
|
||||
targets - a list of available targets
|
||||
toolchains - a list of available toolchains
|
||||
"""
|
||||
for release_target, release_toolchains in get_mbed_official_release("5"):
|
||||
for toolchain in release_toolchains:
|
||||
if (toolchain in allowed_toolchains and
|
||||
toolchain in toolchains and
|
||||
release_target in targets and
|
||||
all(feature in TARGET_MAP[release_target].features
|
||||
for feature in features)):
|
||||
yield release_target, toolchain
|
||||
|
||||
|
||||
def target_cross_ide(allowed_ides,
|
||||
features=[],
|
||||
ides=SUPPORTED_IDES,
|
||||
toolchains=SUPPORTED_TOOLCHAINS):
|
||||
"""Generate pairs of target and ides
|
||||
|
||||
Args:
|
||||
allowed_ides - a list of all possible IDEs
|
||||
|
||||
"""
|
||||
for release_target, release_toolchains in get_mbed_official_release("5"):
|
||||
for ide in allowed_ides:
|
||||
if (release_target in EXPORTERS[ide].TARGETS and
|
||||
EXPORTERS[ide].TOOLCHAIN in toolchains and
|
||||
ide in ides and
|
||||
all(feature in TARGET_MAP[release_target].features
|
||||
for feature in features)):
|
||||
yield release_target, ide
|
||||
|
||||
|
||||
def main():
|
||||
"""Entry point"""
|
||||
|
@ -106,57 +47,29 @@ def main():
|
|||
return args.fn(args, config)
|
||||
|
||||
|
||||
def do_export(args):
|
||||
def do_export(args, config):
|
||||
"""Do export and build step"""
|
||||
def print_message(message, name):
|
||||
print(message+ " %s"%name)
|
||||
sys.stdout.flush()
|
||||
results = {}
|
||||
results = lib.export_repos(config, args.ide)
|
||||
|
||||
lib.print_summary(results, export=True)
|
||||
failures = lib.get_num_failures(results, export=True)
|
||||
print("Number of failures = %d" % failures)
|
||||
return failures
|
||||
|
||||
export_failures = []
|
||||
build_failures = []
|
||||
sucesses = []
|
||||
for example, requirements in EXAMPLES.iteritems():
|
||||
ex_name = basename(example)
|
||||
if ex_name != "mbed-os-example-blinky":
|
||||
continue
|
||||
os.chdir(ex_name)
|
||||
for target, ide in target_cross_ide(args.ide,
|
||||
**requirements):
|
||||
example_name = "{} {} {}".format(ex_name, target,
|
||||
ide)
|
||||
print_message("Export:",example_name)
|
||||
proc = subprocess.Popen(["mbed-cli", "export", "-i", ide,
|
||||
"-m", target])
|
||||
proc.wait()
|
||||
if proc.returncode:
|
||||
export_failures.append(example_name)
|
||||
print_message("FAILURE Export:", example_name)
|
||||
else:
|
||||
print_message("SUCCESS Export:", example_name)
|
||||
print_message("Build:", example_name)
|
||||
if EXPORTERS[ide].build(ex_name):
|
||||
print_message("FAILURE Build:", example_name)
|
||||
build_failures.append(example_name)
|
||||
else:
|
||||
print_message("SUCCESS Build:", example_name)
|
||||
sucesses.append(example_name)
|
||||
print_stuff("Passed", sucesses)
|
||||
print_stuff("Failed Export", export_failures)
|
||||
print_stuff("Failed Building", build_failures)
|
||||
return len(export_failures+build_failures)
|
||||
|
||||
|
||||
def do_import(_, config):
|
||||
"""Do the import step of this process"""
|
||||
lib.source_repos(config)
|
||||
return 0
|
||||
|
||||
|
||||
def do_compile(args, config):
|
||||
"""Do the compile step"""
|
||||
results = {}
|
||||
results = lib.compile_repos(config, args.toolchains)
|
||||
|
||||
lib.print_compilation_summary(results)
|
||||
lib.print_summary(results)
|
||||
failures = lib.get_num_failures(results)
|
||||
print("Number of failures = %d" % failures)
|
||||
return failures
|
||||
|
|
|
@ -16,8 +16,10 @@ sys.path.insert(0, ROOT)
|
|||
|
||||
from tools.build_api import get_mbed_official_release
|
||||
from tools.targets import TARGET_MAP
|
||||
from tools.export import EXPORTERS
|
||||
|
||||
SUPPORTED_TOOLCHAINS = ["ARM", "IAR", "GCC_ARM"]
|
||||
SUPPORTED_IDES = ["iar", "uvision", "make_gcc_arm", "make_iar", "make_armc5"]
|
||||
|
||||
def print_list(lst):
|
||||
"""Prints to screen the contents of a list
|
||||
|
@ -30,13 +32,13 @@ def print_list(lst):
|
|||
for thing in lst:
|
||||
print("# %s" % thing)
|
||||
|
||||
def print_compilation_summary(results):
|
||||
"""Prints to screen the results of compiling combinations of example programs,
|
||||
targets and compile chains.
|
||||
def print_summary(results, export=False):
|
||||
"""Prints to screen the results of compiling/exporting combinations of example programs,
|
||||
targets and compile toolchains/IDEs.
|
||||
|
||||
Args:
|
||||
results - results of the compilation stage. See compile_repos() for
|
||||
details of the format.
|
||||
results - results of the compilation stage. See compile_repos() and export_repos()
|
||||
for details of the format.
|
||||
|
||||
"""
|
||||
|
||||
|
@ -48,12 +50,23 @@ def print_compilation_summary(results):
|
|||
print("#")
|
||||
for key, val in results.iteritems():
|
||||
print_list(val[2])
|
||||
|
||||
second_result = "Failed example combinations" if not export else \
|
||||
"Failed export example combinations"
|
||||
|
||||
print("#")
|
||||
print("# Failed example combinations")
|
||||
print("# %s"%second_result)
|
||||
print("#")
|
||||
for key, val in results.iteritems():
|
||||
print_list(val[3])
|
||||
|
||||
if export:
|
||||
print("#")
|
||||
print("# Failed build example combinations")
|
||||
print("#")
|
||||
for key, val in results.iteritems():
|
||||
print_list(val[4])
|
||||
|
||||
print("#")
|
||||
print("#"*80)
|
||||
|
||||
|
@ -81,18 +94,30 @@ def target_cross_toolchain(allowed_toolchains,
|
|||
for feature in features)):
|
||||
yield target, toolchain
|
||||
|
||||
|
||||
def target_cross_ide(allowed_ides,
|
||||
targets=TARGET_MAP.keys()):
|
||||
features=[], targets=[]):
|
||||
"""Generate pairs of target and ides
|
||||
|
||||
Args:
|
||||
allowed_ides - a list of all possible IDEs
|
||||
|
||||
Kwargs:
|
||||
features - the features that must be in the features array of a
|
||||
target
|
||||
targets - a list of available targets
|
||||
"""
|
||||
for release_target, release_toolchains in get_mbed_official_release("5"):
|
||||
if len(targets) == 0:
|
||||
targets=TARGET_MAP.keys()
|
||||
|
||||
for target, toolchains in get_mbed_official_release("5"):
|
||||
for ide in allowed_ides:
|
||||
if release_target in EXPORTERS[ide].TARGETS:
|
||||
yield release_target, ide
|
||||
if (EXPORTERS[ide].TOOLCHAIN in toolchains and
|
||||
target in EXPORTERS[ide].TARGETS and
|
||||
target in targets and
|
||||
all(feature in TARGET_MAP[target].features
|
||||
for feature in features)):
|
||||
yield target, ide
|
||||
|
||||
|
||||
def get_repo_list(example):
|
||||
|
@ -134,7 +159,7 @@ def source_repos(config):
|
|||
|
||||
subprocess.call(["mbed-cli", "import", repo])
|
||||
|
||||
def get_num_failures(results):
|
||||
def get_num_failures(results, export=False):
|
||||
""" Returns the number of failed compilations from the results summary
|
||||
Args:
|
||||
results - results summary of the compilation stage. See compile_repos() for
|
||||
|
@ -146,9 +171,68 @@ def get_num_failures(results):
|
|||
|
||||
for key, val in results.iteritems():
|
||||
num_failures = num_failures + len(val[3])
|
||||
if export:
|
||||
num_failures += len(val[4])
|
||||
|
||||
return num_failures
|
||||
|
||||
|
||||
|
||||
def export_repos(config, ides):
|
||||
def print_message(message, name):
|
||||
print(message+ " %s"%name)
|
||||
sys.stdout.flush()
|
||||
|
||||
results = {}
|
||||
print("\nExporting example repos....\n")
|
||||
for example in config['examples']:
|
||||
export_failures = []
|
||||
build_failures = []
|
||||
successes = []
|
||||
exported = True
|
||||
pass_status = True
|
||||
if example['export']:
|
||||
for repo in get_repo_list(example):
|
||||
example_project_name = basename(repo)
|
||||
os.chdir(example_project_name)
|
||||
# Check that the target, IDE, and features combinations are valid and return a
|
||||
# list of valid combinations to work through
|
||||
for target, ide in target_cross_ide(ides,
|
||||
example['features'],
|
||||
example['targets']):
|
||||
example_name = "{} {} {}".format(example_project_name, target,
|
||||
ide)
|
||||
def status(message):
|
||||
print(message + " %s" % example_name)
|
||||
sys.stdout.flush()
|
||||
|
||||
status("Exporting")
|
||||
proc = subprocess.Popen(["mbed-cli", "export", "-i", ide,
|
||||
"-m", target])
|
||||
proc.wait()
|
||||
if proc.returncode:
|
||||
export_failures.append(example_name)
|
||||
status("FAILURE exporting")
|
||||
else:
|
||||
status("SUCCESS exporting")
|
||||
status("Building")
|
||||
if EXPORTERS[ide].build(example_project_name):
|
||||
status("FAILURE building")
|
||||
build_failures.append(example_name)
|
||||
else:
|
||||
status("SUCCESS building")
|
||||
successes.append(example_name)
|
||||
os.chdir("..")
|
||||
|
||||
if len(build_failures+export_failures) > 0:
|
||||
pass_status= False
|
||||
else:
|
||||
exported = False
|
||||
|
||||
results[example['name']] = [exported, pass_status, successes, export_failures, build_failures]
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def compile_repos(config, toolchains):
|
||||
"""Compiles combinations of example programs, targets and compile chains.
|
||||
|
||||
|
|
Loading…
Reference in New Issue