|
23 | 23 | from time import sleep
|
24 | 24 | from shutil import copy
|
25 | 25 | from os.path import join, abspath, dirname
|
| 26 | +from json import load, dump |
26 | 27 |
|
27 | 28 | # Be sure that the tools directory is in the search path
|
28 | 29 | ROOT = abspath(join(dirname(__file__), ".."))
|
|
54 | 55 | from tools.toolchains import mbedToolchain, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS
|
55 | 56 | from tools.settings import CLI_COLOR_MAP
|
56 | 57 |
|
| 58 | +def merge_metadata(filename, toolchain_report): |
| 59 | + try: |
| 60 | + metadata = load(open(filename)) |
| 61 | + except (IOError, ValueError): |
| 62 | + metadata = {'builds': []} |
| 63 | + for tgt in toolchain_report.values(): |
| 64 | + for tc in tgt.values(): |
| 65 | + for project in tc.values(): |
| 66 | + for build in project: |
| 67 | + metadata['builds'].append(build[0]) |
| 68 | + dump(metadata, open(filename, "wb"), indent=4, separators=(',', ': ')) |
| 69 | + |
57 | 70 | if __name__ == '__main__':
|
58 | 71 | # Parse Options
|
59 | 72 | parser = get_default_options_parser(add_app_config=True)
|
|
177 | 190 | default=False,
|
178 | 191 | help="Link with mbed test library")
|
179 | 192 |
|
| 193 | + parser.add_argument("--metadata", |
| 194 | + dest="metadata", |
| 195 | + default=None, |
| 196 | + help="Dump metadata to this file") |
| 197 | + |
180 | 198 | # Specify a different linker script
|
181 | 199 | parser.add_argument("-l", "--linker", dest="linker_script",
|
182 | 200 | type=argparse_filestring_type,
|
|
249 | 267 | %(toolchain,search_path))
|
250 | 268 |
|
251 | 269 | # Test
|
| 270 | + metadata_blob = {} if options.metadata else None |
252 | 271 | for test_no in p:
|
253 | 272 | test = Test(test_no)
|
254 | 273 | if options.automated is not None: test.automated = options.automated
|
|
287 | 306 | clean=options.clean,
|
288 | 307 | verbose=options.verbose,
|
289 | 308 | notify=notify,
|
| 309 | + report=metadata_blob, |
290 | 310 | silent=options.silent,
|
291 | 311 | macros=options.macros,
|
292 | 312 | jobs=options.jobs,
|
|
342 | 362 | print "[ERROR] %s" % str(e)
|
343 | 363 |
|
344 | 364 | sys.exit(1)
|
| 365 | + if options.metadata: |
| 366 | + merge_metadata(options.metadata, metadata_blob) |
0 commit comments