mirror of https://github.com/ARMmbed/mbed-os.git
Add --build-data flag to mbed test
parent
aeb6109717
commit
808279911c
|
@ -21,9 +21,11 @@ import datetime
|
|||
from types import ListType
|
||||
from shutil import rmtree
|
||||
from os.path import join, exists, dirname, basename, abspath, normpath, splitext
|
||||
from os.path import relpath
|
||||
from os import linesep, remove, makedirs
|
||||
from time import time
|
||||
from intelhex import IntelHex
|
||||
from json import load, dump
|
||||
|
||||
from tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException,\
|
||||
ToolException, InvalidReleaseTargetException, intelhex_offset
|
||||
|
@ -1365,3 +1367,22 @@ def write_build_report(build_report, template_filename, filename):
|
|||
placeholder.write(template.render(
|
||||
failing_builds=build_report_failing,
|
||||
passing_builds=build_report_passing))
|
||||
|
||||
|
||||
def merge_build_data(filename, toolchain_report):
|
||||
path_to_file = dirname(abspath(filename))
|
||||
try:
|
||||
build_data = load(open(filename))
|
||||
except (IOError, ValueError):
|
||||
build_data = {'builds': []}
|
||||
for tgt in toolchain_report.values():
|
||||
for tc in tgt.values():
|
||||
for project in tc.values():
|
||||
for build in project:
|
||||
try:
|
||||
build[0]['elf'] = relpath(build[0]['elf'], path_to_file)
|
||||
build[0]['bin'] = relpath(build[0]['bin'], path_to_file)
|
||||
except KeyError:
|
||||
pass
|
||||
build_data['builds'].append(build[0])
|
||||
dump(build_data, open(filename, "wb"), indent=4, separators=(',', ': '))
|
||||
|
|
|
@ -49,24 +49,13 @@ from tools.build_api import build_project
|
|||
from tools.build_api import mcu_toolchain_matrix
|
||||
from tools.build_api import mcu_toolchain_list
|
||||
from tools.build_api import mcu_target_list
|
||||
from tools.build_api import merge_build_data
|
||||
from utils import argparse_filestring_type
|
||||
from utils import argparse_many
|
||||
from utils import argparse_dir_not_parent
|
||||
from tools.toolchains import mbedToolchain, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS
|
||||
from tools.settings import CLI_COLOR_MAP
|
||||
|
||||
def merge_build_data(filename, toolchain_report):
|
||||
try:
|
||||
build_data = load(open(filename))
|
||||
except (IOError, ValueError):
|
||||
build_data = {'builds': []}
|
||||
for tgt in toolchain_report.values():
|
||||
for tc in tgt.values():
|
||||
for project in tc.values():
|
||||
for build in project:
|
||||
build_data['builds'].append(build[0])
|
||||
dump(build_data, open(filename, "wb"), indent=4, separators=(',', ': '))
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Parse Options
|
||||
parser = get_default_options_parser(add_app_config=True)
|
||||
|
|
|
@ -31,6 +31,7 @@ from tools.test_api import test_path_to_name, find_tests, print_tests, build_tes
|
|||
from tools.options import get_default_options_parser, extract_profile
|
||||
from tools.build_api import build_project, build_library
|
||||
from tools.build_api import print_build_memory_usage
|
||||
from tools.build_api import merge_build_data
|
||||
from tools.targets import TARGET_MAP
|
||||
from tools.utils import mkdir, ToolException, NotSupportedException, args_error
|
||||
from tools.test_exporters import ReportExporter, ResultExporterType
|
||||
|
@ -88,6 +89,10 @@ if __name__ == '__main__':
|
|||
|
||||
parser.add_argument("--build-report-junit", dest="build_report_junit",
|
||||
default=None, help="Destination path for a build report in the JUnit xml format")
|
||||
parser.add_argument("--build-data",
|
||||
dest="build_data",
|
||||
default=None,
|
||||
help="Dump build_data to this file")
|
||||
|
||||
parser.add_argument("-v", "--verbose",
|
||||
action="store_true",
|
||||
|
@ -175,16 +180,12 @@ if __name__ == '__main__':
|
|||
profile = extract_profile(parser, options, toolchain)
|
||||
try:
|
||||
# Build sources
|
||||
build_library(base_source_paths, options.build_dir, mcu, toolchain,
|
||||
jobs=options.jobs,
|
||||
clean=options.clean,
|
||||
report=build_report,
|
||||
properties=build_properties,
|
||||
name="mbed-build",
|
||||
macros=options.macros,
|
||||
verbose=options.verbose,
|
||||
notify=notify,
|
||||
archive=False,
|
||||
build_library(base_source_paths, options.build_dir, mcu,
|
||||
toolchain, jobs=options.jobs,
|
||||
clean=options.clean, report=build_report,
|
||||
properties=build_properties, name="mbed-build",
|
||||
macros=options.macros, verbose=options.verbose,
|
||||
notify=notify, archive=False,
|
||||
app_config=options.app_config,
|
||||
build_profile=profile)
|
||||
|
||||
|
@ -245,6 +246,8 @@ if __name__ == '__main__':
|
|||
|
||||
print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build")
|
||||
status = print_report_exporter.report(build_report)
|
||||
if options.build_data:
|
||||
merge_build_data(options.build_data, build_report)
|
||||
|
||||
if status:
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Reference in New Issue