|
11 | 11 | ROOT = abspath(dirname(dirname(dirname(dirname(__file__)))))
|
12 | 12 | sys.path.insert(0, ROOT)
|
13 | 13 |
|
14 |
| -from tools.build_api import get_mbed_official_release |
15 |
| -from tools.targets import TARGET_MAP |
16 | 14 | from tools.utils import argparse_force_uppercase_type
|
17 |
| - |
18 |
| - |
19 |
| -EXAMPLES = json.load(open(os.path.join(os.path.dirname(__file__), |
20 |
| - "examples.json"))) |
21 |
| - |
22 |
| -def print_stuff(name, lst): |
23 |
| - if lst: |
24 |
| - print("#"*80) |
25 |
| - print("# {} example combinations".format(name)) |
26 |
| - print("#") |
27 |
| - for thing in lst: |
28 |
| - print(thing) |
29 |
| - |
30 |
| - |
31 |
| -SUPPORTED_TOOLCHAINS = ["ARM", "IAR", "GCC_ARM"] |
32 |
| - |
33 |
| - |
34 |
| -def target_cross_toolchain(allowed_toolchains, |
35 |
| - features=[], targets=TARGET_MAP.keys(), |
36 |
| - toolchains=SUPPORTED_TOOLCHAINS): |
37 |
| - """Generate pairs of target and toolchains |
38 |
| -
|
39 |
| - Args: |
40 |
| - allowed_toolchains - a list of all possible toolchains |
41 |
| -
|
42 |
| - Kwargs: |
43 |
| - features - the features that must be in the features array of a |
44 |
| - target |
45 |
| - targets - a list of available targets |
46 |
| - toolchains - a list of available toolchains |
47 |
| - """ |
48 |
| - for release_target, release_toolchains in get_mbed_official_release("5"): |
49 |
| - for toolchain in release_toolchains: |
50 |
| - if (toolchain in allowed_toolchains and |
51 |
| - toolchain in toolchains and |
52 |
| - release_target in targets and |
53 |
| - all(feature in TARGET_MAP[release_target].features |
54 |
| - for feature in features)): |
55 |
| - yield release_target, toolchain |
| 15 | +import examples_lib as lib |
| 16 | +from examples_lib import SUPPORTED_TOOLCHAINS |
56 | 17 |
|
57 | 18 |
|
58 | 19 | def main():
|
59 | 20 | """Entry point"""
|
60 | 21 | parser = ArgumentParser()
|
| 22 | + parser.add_argument("-c", dest="config", default="examples.json") |
61 | 23 | subparsers = parser.add_subparsers()
|
62 | 24 | import_cmd = subparsers.add_parser("import")
|
63 | 25 | import_cmd.set_defaults(fn=do_import)
|
| 26 | + version_cmd = subparsers.add_parser("tag") |
| 27 | + version_cmd.add_argument("tag") |
| 28 | + version_cmd.set_defaults(fn=do_versionning) |
64 | 29 | compile_cmd = subparsers.add_parser("compile")
|
65 | 30 | compile_cmd.set_defaults(fn=do_compile)
|
66 | 31 | compile_cmd.add_argument(
|
67 | 32 | "toolchains", nargs="*", default=SUPPORTED_TOOLCHAINS,
|
68 | 33 | type=argparse_force_uppercase_type(SUPPORTED_TOOLCHAINS,
|
69 | 34 | "toolchain"))
|
70 | 35 | args = parser.parse_args()
|
71 |
| - return args.fn(args) |
| 36 | + config = json.load(open(os.path.join(os.path.dirname(__file__), |
| 37 | + args.config))) |
72 | 38 |
|
| 39 | + return args.fn(args, config) |
73 | 40 |
|
74 |
| -def do_import(_): |
| 41 | + |
| 42 | +def do_import(_, config): |
75 | 43 | """Do the import step of this process"""
|
76 |
| - for example, _ in EXAMPLES.iteritems(): |
77 |
| - subprocess.call(["mbed-cli", "import", example]) |
| 44 | + lib.source_repos(config) |
78 | 45 | return 0
|
79 | 46 |
|
80 |
| - |
81 |
| -def do_compile(args): |
| 47 | +def do_compile(args, config): |
82 | 48 | """Do the compile step"""
|
83 |
| - failures = [] |
84 |
| - sucesses = [] |
85 |
| - for example, requirements in EXAMPLES.iteritems(): |
86 |
| - os.chdir(basename(example)) |
87 |
| - for target, toolchain in target_cross_toolchain(args.toolchains, |
88 |
| - **requirements): |
89 |
| - proc = subprocess.Popen(["mbed-cli", "compile", "-t", toolchain, |
90 |
| - "-m", target, "--silent"]) |
91 |
| - proc.wait() |
92 |
| - example_name = "{} {} {}".format(basename(example), target, |
93 |
| - toolchain) |
94 |
| - if proc.returncode: |
95 |
| - failures.append(example_name) |
96 |
| - else: |
97 |
| - sucesses.append(example_name) |
98 |
| - os.chdir("..") |
| 49 | + results = {} |
| 50 | + results = lib.compile_repos(config, args.toolchains) |
| 51 | + |
| 52 | + lib.print_compilation_summary(results) |
| 53 | + failures = lib.get_num_failures(results) |
| 54 | + print("Number of failures = %d" % failures) |
| 55 | + return failures |
| 56 | + |
| 57 | +def do_versionning(args, config): |
| 58 | + """ Test update the mbed-os to the version specified by the tag """ |
| 59 | + lib.update_mbedos_version(config, args.tag) |
| 60 | + return 0 |
99 | 61 |
|
100 |
| - print_stuff("Passed", sucesses) |
101 |
| - print_stuff("Failed", failures) |
102 |
| - return len(failures) |
103 | 62 |
|
104 | 63 | if __name__ == "__main__":
|
105 | 64 | sys.exit(main())
|
0 commit comments