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.
pull/2102/head
Bogdan Marinescu 2016-07-05 15:40:12 +03:00
parent 0aa23a4867
commit e3d29fe5d2
1 changed files with 10 additions and 3 deletions

View File

@ -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)