Improvements to Sam's platform_init.c commit

pull/234/head
Bogdan Marinescu 2014-03-25 11:43:54 +00:00
parent d4c04e866e
commit 71b306a2d4
5 changed files with 16 additions and 19 deletions

View File

@ -181,23 +181,20 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F
# Common Sources
mbed_resources = toolchain.scan_resources(MBED_COMMON)
objects += toolchain.compile_sources(mbed_resources, TMP_PATH, [MBED_LIBRARIES, BUILD_TARGET])
# Keep retargeting as a standalone object to be sure the
# C standard library symbols get overridden
retargeting = None
for o in objects:
if o.endswith('retarget.o'):
retargeting = o
objects.remove(retargeting)
# We need to have a file that overrides weak delcatations on a per board basis and the
# lesser evil is to pull in this file if it extist rather than add board specific
# startup code in the /targets/cmsis directory
platform_initialize = None
for p in objects:
if p.endswith('platform_init.o'):
platform_initialize = p
objects.remove(platform_initialize)
toolchain.build_library(objects, BUILD_TOOLCHAIN, "mbed")
toolchain.copy_files(retargeting, BUILD_TOOLCHAIN)
toolchain.copy_files(platform_initialize, BUILD_TOOLCHAIN)
# A number of compiled files need to be copied as objects as opposed to
# being part of the mbed library, for reasons that have to do with the way
# the linker search for symbols in archives. These are:
# - retarget.o: to make sure that the C standard lib symbols get overridden
# - board.o: mbed_die is weak
# - mbed_overrides.o: this contains platform overrides of various weak SDK functions
separate_names, separate_objects = ['retarget.o', 'board.o', 'mbed_overrides.o'], []
for o in objects:
for name in separate_names:
if o.endswith(name):
separate_objects.append(o)
for o in separate_objects:
objects.remove(o)
toolchain.build_library(objects, BUILD_TOOLCHAIN, "mbed")
for o in separate_objects:
toolchain.copy_files(o, BUILD_TOOLCHAIN)