mirror of https://github.com/ARMmbed/mbed-os.git
Re-factor mbed2 lib builds to use prepare_toolchain
The prior patch in this series makes the assumption that any building will go through `build_api.prepare_toolchain`. This was not a valid assumption for the mbed2 build process. So, instead of maintaining 2 ways of using the toolchain classes, I elected to unify on `prepare_toolchain`.pull/3852/head
parent
fbb6f71be8
commit
51aa3330dd
|
@ -731,6 +731,9 @@ def build_library(src_paths, build_path, target, toolchain_name,
|
||||||
### Legacy methods ###
|
### Legacy methods ###
|
||||||
######################
|
######################
|
||||||
|
|
||||||
|
def mbed2_obj_path(target_name, toolchain_name):
|
||||||
|
return join("TARGET_" + target_name, "TOOLCHAIN_" + toolchain_name)
|
||||||
|
|
||||||
def build_lib(lib_id, target, toolchain_name, verbose=False,
|
def build_lib(lib_id, target, toolchain_name, verbose=False,
|
||||||
clean=False, macros=None, notify=None, jobs=1, silent=False,
|
clean=False, macros=None, notify=None, jobs=1, silent=False,
|
||||||
report=None, properties=None, extra_verbose=False,
|
report=None, properties=None, extra_verbose=False,
|
||||||
|
@ -807,20 +810,23 @@ def build_lib(lib_id, target, toolchain_name, verbose=False,
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Toolchain instance
|
# Toolchain instance
|
||||||
toolchain = TOOLCHAIN_CLASSES[toolchain_name](
|
# Create the desired build directory structure
|
||||||
target, macros=macros, notify=notify, silent=silent,
|
bin_path = join(build_path, mbed2_obj_path(target.name, toolchain_name))
|
||||||
extra_verbose=extra_verbose, build_profile=build_profile)
|
mkdir(bin_path)
|
||||||
toolchain.VERBOSE = verbose
|
tmp_path = join(build_path, '.temp', mbed2_obj_path(target.name,
|
||||||
toolchain.jobs = jobs
|
toolchain_name))
|
||||||
toolchain.build_all = clean
|
mkdir(tmp_path)
|
||||||
toolchain.build_dir = build_path
|
|
||||||
|
toolchain = prepare_toolchain(
|
||||||
|
src_paths, tmp_path, target, toolchain_name, macros=macros,
|
||||||
|
notify=notify, silent=silent, extra_verbose=extra_verbose,
|
||||||
|
build_profile=build_profile, jobs=jobs, clean=clean)
|
||||||
|
|
||||||
toolchain.info("Building library %s (%s, %s)" %
|
toolchain.info("Building library %s (%s, %s)" %
|
||||||
(name.upper(), target.name, toolchain_name))
|
(name.upper(), target.name, toolchain_name))
|
||||||
|
|
||||||
# Take into account the library configuration (MBED_CONFIG_FILE)
|
# Take into account the library configuration (MBED_CONFIG_FILE)
|
||||||
config = Config(target)
|
config = toolchain.config
|
||||||
toolchain.config = config
|
|
||||||
config.add_config_files([MBED_CONFIG_FILE])
|
config.add_config_files([MBED_CONFIG_FILE])
|
||||||
|
|
||||||
# Scan Resources
|
# Scan Resources
|
||||||
|
@ -851,11 +857,6 @@ def build_lib(lib_id, target, toolchain_name, verbose=False,
|
||||||
config.load_resources(res)
|
config.load_resources(res)
|
||||||
toolchain.set_config_data(toolchain.config.get_config_data())
|
toolchain.set_config_data(toolchain.config.get_config_data())
|
||||||
|
|
||||||
# Create the desired build directory structure
|
|
||||||
bin_path = join(build_path, toolchain.obj_path)
|
|
||||||
mkdir(bin_path)
|
|
||||||
tmp_path = join(build_path, '.temp', toolchain.obj_path)
|
|
||||||
mkdir(tmp_path)
|
|
||||||
|
|
||||||
# Copy Headers
|
# Copy Headers
|
||||||
for resource in resources:
|
for resource in resources:
|
||||||
|
@ -952,30 +953,24 @@ def build_mbed_libs(target, toolchain_name, verbose=False,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Toolchain
|
|
||||||
toolchain = TOOLCHAIN_CLASSES[toolchain_name](
|
|
||||||
target, macros=macros, notify=notify, silent=silent,
|
|
||||||
extra_verbose=extra_verbose, build_profile=build_profile)
|
|
||||||
toolchain.VERBOSE = verbose
|
|
||||||
toolchain.jobs = jobs
|
|
||||||
toolchain.build_all = clean
|
|
||||||
|
|
||||||
tmp_path = join(MBED_LIBRARIES, '.temp', toolchain.obj_path)
|
|
||||||
mkdir(tmp_path)
|
|
||||||
|
|
||||||
toolchain.build_dir = tmp_path
|
|
||||||
|
|
||||||
# Take into account the library configuration (MBED_CONFIG_FILE)
|
|
||||||
config = Config(target)
|
|
||||||
toolchain.config = config
|
|
||||||
config.add_config_files([MBED_CONFIG_FILE])
|
|
||||||
toolchain.set_config_data(toolchain.config.get_config_data())
|
|
||||||
|
|
||||||
# Source and Build Paths
|
# Source and Build Paths
|
||||||
build_target = join(MBED_LIBRARIES, "TARGET_" + target.name)
|
build_target = join(MBED_LIBRARIES, "TARGET_" + target.name)
|
||||||
build_toolchain = join(build_target, "TOOLCHAIN_" + toolchain.name)
|
build_toolchain = join(build_target, "TOOLCHAIN_" + toolchain_name)
|
||||||
mkdir(build_toolchain)
|
mkdir(build_toolchain)
|
||||||
|
|
||||||
|
# Toolchain
|
||||||
|
tmp_path = join(MBED_LIBRARIES, '.temp', mbed2_obj_path(target.name, toolchain_name))
|
||||||
|
mkdir(tmp_path)
|
||||||
|
|
||||||
|
toolchain = prepare_toolchain(
|
||||||
|
[""], tmp_path, target, toolchain_name, macros=macros,
|
||||||
|
notify=notify, silent=silent, extra_verbose=extra_verbose,
|
||||||
|
build_profile=build_profile, jobs=jobs, clean=clean)
|
||||||
|
|
||||||
|
# Take into account the library configuration (MBED_CONFIG_FILE)
|
||||||
|
config = toolchain.config
|
||||||
|
config.add_config_files([MBED_CONFIG_FILE])
|
||||||
|
toolchain.set_config_data(toolchain.config.get_config_data())
|
||||||
|
|
||||||
# CMSIS
|
# CMSIS
|
||||||
toolchain.info("Building library %s (%s, %s)" %
|
toolchain.info("Building library %s (%s, %s)" %
|
||||||
|
|
|
@ -269,7 +269,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bin_file = build_project(test.source_dir, build_dir, mcu, toolchain,
|
bin_file = build_project(test.source_dir, build_dir, mcu, toolchain,
|
||||||
test.dependencies,
|
set(test.dependencies),
|
||||||
linker_script=options.linker_script,
|
linker_script=options.linker_script,
|
||||||
clean=options.clean,
|
clean=options.clean,
|
||||||
verbose=options.verbose,
|
verbose=options.verbose,
|
||||||
|
|
Loading…
Reference in New Issue