Skip to content

Commit 035ddfb

Browse files
committed
Add an option to make.py to dump build metadata
1 parent da9c10b commit 035ddfb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tools/make.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from time import sleep
2424
from shutil import copy
2525
from os.path import join, abspath, dirname
26+
from json import load, dump
2627

2728
# Be sure that the tools directory is in the search path
2829
ROOT = abspath(join(dirname(__file__), ".."))
@@ -54,6 +55,18 @@
5455
from tools.toolchains import mbedToolchain, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS
5556
from tools.settings import CLI_COLOR_MAP
5657

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+
5770
if __name__ == '__main__':
5871
# Parse Options
5972
parser = get_default_options_parser(add_app_config=True)
@@ -177,6 +190,11 @@
177190
default=False,
178191
help="Link with mbed test library")
179192

193+
parser.add_argument("--metadata",
194+
dest="metadata",
195+
default=None,
196+
help="Dump metadata to this file")
197+
180198
# Specify a different linker script
181199
parser.add_argument("-l", "--linker", dest="linker_script",
182200
type=argparse_filestring_type,
@@ -249,6 +267,7 @@
249267
%(toolchain,search_path))
250268

251269
# Test
270+
metadata_blob = {} if options.metadata else None
252271
for test_no in p:
253272
test = Test(test_no)
254273
if options.automated is not None: test.automated = options.automated
@@ -287,6 +306,7 @@
287306
clean=options.clean,
288307
verbose=options.verbose,
289308
notify=notify,
309+
report=metadata_blob,
290310
silent=options.silent,
291311
macros=options.macros,
292312
jobs=options.jobs,
@@ -342,3 +362,5 @@
342362
print "[ERROR] %s" % str(e)
343363

344364
sys.exit(1)
365+
if options.metadata:
366+
merge_metadata(options.metadata, metadata_blob)

0 commit comments

Comments
 (0)