mirror of https://github.com/ARMmbed/mbed-os.git
Allow command-line filtering of toolchains
parent
f7a1d1f749
commit
1f0afebbbc
|
@ -1,5 +1,6 @@
|
||||||
""" import and bulid a bunch of example programs """
|
""" import and bulid a bunch of example programs """
|
||||||
|
|
||||||
|
from argparse import ArgumentParser
|
||||||
import os
|
import os
|
||||||
from os.path import dirname, abspath, basename
|
from os.path import dirname, abspath, basename
|
||||||
import os.path
|
import os.path
|
||||||
|
@ -12,13 +13,14 @@ sys.path.insert(0, ROOT)
|
||||||
|
|
||||||
from tools.build_api import get_mbed_official_release
|
from tools.build_api import get_mbed_official_release
|
||||||
from tools.targets import TARGET_MAP
|
from tools.targets import TARGET_MAP
|
||||||
|
from tools.utils import argparse_force_uppercase_type
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES = json.load(open(os.path.join(os.path.dirname(__file__),
|
EXAMPLES = json.load(open(os.path.join(os.path.dirname(__file__),
|
||||||
"examples.json")))
|
"examples.json")))
|
||||||
|
|
||||||
def print_stuff(name, lst):
|
def print_stuff(name, lst):
|
||||||
if list:
|
if lst:
|
||||||
print("#"*80)
|
print("#"*80)
|
||||||
print("# {} example combinations".format(name))
|
print("# {} example combinations".format(name))
|
||||||
print("#")
|
print("#")
|
||||||
|
@ -26,28 +28,53 @@ def print_stuff(name, lst):
|
||||||
print(thing)
|
print(thing)
|
||||||
|
|
||||||
|
|
||||||
|
SUPPORTED_TOOLCHAINS = ["ARM", "IAR", "GCC_ARM"]
|
||||||
|
|
||||||
|
|
||||||
|
def target_cross_toolchain(required_features, allowed_toolchains):
|
||||||
|
"""Generate pairs of target and toolchains
|
||||||
|
|
||||||
|
Args:
|
||||||
|
required_features - the features that must be in the features array of a
|
||||||
|
target
|
||||||
|
allowed_toolchains - a list of all possible toolchains
|
||||||
|
"""
|
||||||
|
for target, toolchains in get_mbed_official_release("5"):
|
||||||
|
for toolchain in toolchains:
|
||||||
|
if (toolchain in allowed_toolchains and
|
||||||
|
all(feature in TARGET_MAP[target].features
|
||||||
|
for feature in required_features)):
|
||||||
|
yield target, toolchain
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Entry point"""
|
"""Entry point"""
|
||||||
|
parser = ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
"toolchains", nargs="*", default=SUPPORTED_TOOLCHAINS,
|
||||||
|
type=argparse_force_uppercase_type(SUPPORTED_TOOLCHAINS,
|
||||||
|
"toolchain"))
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
failures = []
|
failures = []
|
||||||
sucesses = []
|
sucesses = []
|
||||||
for example, build_features in EXAMPLES.iteritems():
|
for example, build_features in EXAMPLES.iteritems():
|
||||||
subprocess.call(["mbed-cli", "import", example])
|
subprocess.call(["mbed-cli", "import", example])
|
||||||
os.chdir(basename(example))
|
os.chdir(basename(example))
|
||||||
for target, toolchains in [(target, toolchains) for target, toolchains
|
for target, toolchain in target_cross_toolchain(build_features,
|
||||||
in get_mbed_official_release("5") if
|
args.toolchains):
|
||||||
all(feature in TARGET_MAP[target].features
|
proc = subprocess.Popen(["mbed-cli", "compile", "-t",
|
||||||
for feature in build_features)]:
|
toolchain, "-m", target])
|
||||||
for toolchain in toolchains:
|
proc.wait()
|
||||||
proc = subprocess.Popen(["mbed-cli", "compile", "-t",
|
example_name = "{} {} {}".format(basename(example), target,
|
||||||
toolchain, "-m", target])
|
toolchain)
|
||||||
proc.wait()
|
if proc.returncode:
|
||||||
example_name = "{} {} {}".format(basename(example), target,
|
failures.append(example_name)
|
||||||
toolchain)
|
else:
|
||||||
if proc.returncode:
|
sucesses.append(example_name)
|
||||||
failures.append(example_name)
|
|
||||||
else:
|
|
||||||
sucesses.append(example_name)
|
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
|
||||||
print_stuff("Passed", sucesses)
|
print_stuff("Passed", sucesses)
|
||||||
print_stuff("Failed", failures)
|
print_stuff("Failed", failures)
|
||||||
return len(failures)
|
return len(failures)
|
||||||
|
|
Loading…
Reference in New Issue