|
1 | 1 | """ import and bulid a bunch of example programs """
|
2 | 2 |
|
3 | 3 | import os
|
| 4 | +from os.path import dirname, abspath, basename |
4 | 5 | import os.path
|
5 | 6 | import sys
|
6 | 7 | import subprocess
|
7 | 8 | import json
|
8 | 9 |
|
| 10 | +ROOT = abspath(dirname(dirname(dirname(dirname(__file__))))) |
| 11 | +sys.path.insert(0, ROOT) |
| 12 | + |
| 13 | +from tools.build_api import get_mbed_official_release |
| 14 | +from tools.targets import TARGET_MAP |
| 15 | + |
9 | 16 |
|
10 | 17 | EXAMPLES = json.load(open(os.path.join(os.path.dirname(__file__),
|
11 | 18 | "examples.json")))
|
12 | 19 |
|
13 |
| -BUILD_TOOLCHAINS = [ |
14 |
| - "ARM", |
15 |
| - "GCC_ARM", |
16 |
| - "IAR", |
17 |
| -] |
| 20 | +def print_stuff(name, lst): |
| 21 | + if list: |
| 22 | + print("#"*80) |
| 23 | + print("# {} example combinations".format(name)) |
| 24 | + print("#") |
| 25 | + for thing in lst: |
| 26 | + print(thing) |
| 27 | + |
18 | 28 |
|
19 | 29 | def main():
|
20 | 30 | """Entry point"""
|
21 | 31 | failures = []
|
22 |
| - for example, build_targets in EXAMPLES.iteritems(): |
| 32 | + sucesses = [] |
| 33 | + for example, build_features in EXAMPLES.iteritems(): |
23 | 34 | subprocess.call(["mbed-cli", "import", example])
|
24 |
| - os.chdir(os.path.basename(example)) |
25 |
| - for toolchain in BUILD_TOOLCHAINS: |
26 |
| - for target in build_targets: |
| 35 | + os.chdir(basename(example)) |
| 36 | + for target, toolchains in [(target, toolchains) for target, toolchains |
| 37 | + in get_mbed_official_release("5") if |
| 38 | + all(feature in TARGET_MAP[target].features |
| 39 | + for feature in build_features)]: |
| 40 | + for toolchain in toolchains: |
27 | 41 | proc = subprocess.Popen(["mbed-cli", "compile", "-t",
|
28 | 42 | toolchain, "-m", target])
|
29 | 43 | proc.wait()
|
| 44 | + example_name = "{} {} {}".format(basename(example), target, |
| 45 | + toolchain) |
30 | 46 | if proc.returncode:
|
31 |
| - failures.append("{} {} {}".format(example, target, |
32 |
| - toolchain)) |
| 47 | + failures.append(example_name) |
| 48 | + else: |
| 49 | + sucesses.append(example_name) |
33 | 50 | os.chdir("..")
|
34 |
| - if failures: |
35 |
| - print("#"*80) |
36 |
| - print("# Failed example combinations") |
37 |
| - print("#") |
38 |
| - for fail in failures: |
39 |
| - print(fail) |
| 51 | + print_stuff("Passed", sucesses) |
| 52 | + print_stuff("Failed", failures) |
40 | 53 | return len(failures)
|
41 | 54 |
|
42 | 55 | if __name__ == "__main__":
|
|
0 commit comments