Skip to content

Commit e3d29fe

Browse files
author
Bogdan Marinescu
committed
Improve configuration handling in build_project
The configuration object is now created early in the build_project function. This way, if there's a mbed_app.json that contains a custom target, that target is taken into account. This is useful (for example) when compiling tests for an application that defines a custom target.
1 parent 0aa23a4 commit e3d29fe

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tools/build_api.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,16 @@ def build_library(src_paths, build_path, target, toolchain_name,
282282
# We will use default project name based on project folder name
283283
name = project_name
284284

285+
# If the configuration object was not yet created, create it now
286+
config = Config(target, src_paths)
287+
288+
# If the 'target' argument is a string, convert it to a target instance
289+
if isinstance(target, str):
290+
try:
291+
target = TARGET_MAP[target]
292+
except KeyError:
293+
raise KeyError("Target '%s' not found" % target)
294+
285295
if report != None:
286296
start = time()
287297

@@ -355,9 +365,6 @@ def build_library(src_paths, build_path, target, toolchain_name,
355365
else:
356366
tmp_path = build_path
357367

358-
# Handle configuration
359-
config = Config(target)
360-
361368
# Load resources into the config system which might expand/modify resources based on config data
362369
resources = config.load_resources(resources)
363370

0 commit comments

Comments
 (0)