diff --git a/tools/build_api.py b/tools/build_api.py index 9ef249f963..f8afdc513b 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -282,6 +282,16 @@ def build_library(src_paths, build_path, target, toolchain_name, # We will use default project name based on project folder name name = project_name + # If the configuration object was not yet created, create it now + config = Config(target, src_paths) + + # If the 'target' argument is a string, convert it to a target instance + if isinstance(target, str): + try: + target = TARGET_MAP[target] + except KeyError: + raise KeyError("Target '%s' not found" % target) + if report != None: start = time() @@ -355,9 +365,6 @@ def build_library(src_paths, build_path, target, toolchain_name, else: tmp_path = build_path - # Handle configuration - config = Config(target) - # Load resources into the config system which might expand/modify resources based on config data resources = config.load_resources(resources) diff --git a/tools/test.py b/tools/test.py index bdc9bb9c9d..4189650286 100644 --- a/tools/test.py +++ b/tools/test.py @@ -132,7 +132,7 @@ if __name__ == '__main__': base_source_paths = ['.'] - target = TARGET_MAP[options.mcu] + target = options.mcu build_report = {} build_properties = {} diff --git a/tools/test_api.py b/tools/test_api.py index 6f3494af3f..06ee67612a 100644 --- a/tools/test_api.py +++ b/tools/test_api.py @@ -2030,9 +2030,11 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name, execution_directory = "." base_path = norm_relative_path(build_path, execution_directory) + + target_name = target if isinstance(target, str) else target.name test_build = { - "platform": target.name, + "platform": target_name, "toolchain": toolchain_name, "base_path": base_path, "baud_rate": 9600, @@ -2086,7 +2088,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name, print 'Image: %s'% bin_file test_builds = {} - test_builds["%s-%s" % (target.name, toolchain_name)] = test_build + test_builds["%s-%s" % (target_name, toolchain_name)] = test_build return result, test_builds