mirror of https://github.com/ARMmbed/mbed-os.git
simplify the complicated removal of dependency sources
add hex file generationpull/5476/head
parent
6f667e5ca2
commit
c29945b1be
|
@ -30,7 +30,7 @@ SET(CMAKE_CXX_FLAGS "{{cxx_flags}} -include mbed_config.h")
|
|||
SET(CMAKE_ASM_FLAGS "{{asm_flags}} -include mbed_config.h")
|
||||
SET(CMAKE_CXX_LINK_FLAGS "{{ld_flags}}")
|
||||
{% if pp -%}
|
||||
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_INK_FLAGS} {{link_script_option}} ${CMAKE_BINARY_DIR}/{{name}}.link_script.ld ${LD_SYS_LIBS}")
|
||||
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} ${LD_SYS_LIBS} {{link_script_option}} ${CMAKE_BINARY_DIR}/{{name}}.link_script.ld")
|
||||
{%- endif %}
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
|
@ -48,21 +48,26 @@ ADD_LIBRARY({{libname}} STATIC
|
|||
{% endfor %}
|
||||
|
||||
# executable {{name}}
|
||||
ADD_EXECUTABLE({{name}}.elf
|
||||
ADD_EXECUTABLE({{name}}
|
||||
{% for src in sources %}{{src}}
|
||||
{% endfor %})
|
||||
TARGET_LINK_LIBRARIES({{name}}.elf
|
||||
{% for libname in dependencies %}{{libname}}
|
||||
TARGET_LINK_LIBRARIES({{name}}
|
||||
{% for libname in dependencies.keys()|sort(reverse=true) %}{{libname}}
|
||||
{% endfor %})
|
||||
|
||||
{% if pp -%}
|
||||
add_custom_command(TARGET {{name}}.elf PRE_LINK
|
||||
add_custom_command(TARGET {{name}} PRE_LINK
|
||||
COMMAND "{{pp}}" {{pp_flags}} {{linker_script}} -o ${CMAKE_CURRENT_BINARY_DIR}/{{name}}.link_script.ld
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/{{name}}.link_script.ld"
|
||||
)
|
||||
{%- endif %}
|
||||
|
||||
add_custom_command(TARGET {{name}} POST_BUILD
|
||||
COMMAND ${ELF2BIN} -O ihex $<TARGET_FILE:{{name}}> $<TARGET_FILE:{{name}}>.hex
|
||||
)
|
||||
|
||||
|
||||
##########################################################################
|
||||
# mbed-cli specific targets
|
||||
##########################################################################
|
||||
|
|
|
@ -73,10 +73,9 @@ class CMake(Exporter):
|
|||
depSources = {k: v for k, v in depSources.items() if len(v) != 0}
|
||||
|
||||
# remove all source files that ended up being part of one of the dependencies
|
||||
# we flatten the list of source files from all dependencies and
|
||||
# then only add file to srcs if its not in that list
|
||||
# (basically srcs = allSourcefiles - flatten(depSources.values())
|
||||
srcs = [f for f in allSourceFiles if f not in [item for sublist in depSources.values() for item in sublist]]
|
||||
srcs = allSourceFiles
|
||||
for dep in depSources.values():
|
||||
srcs.difference_update(dep)
|
||||
|
||||
# additional libraries
|
||||
libraries = [self.prepare_lib(basename(lib)) for lib in self.resources.libraries]
|
||||
|
@ -85,7 +84,7 @@ class CMake(Exporter):
|
|||
ctx = {
|
||||
'name': self.project_name,
|
||||
'target': self.target,
|
||||
'sources': srcs,
|
||||
'sources': sorted(srcs),
|
||||
'dependencies': depSources,
|
||||
'libraries': libraries,
|
||||
'ld_sys_libs': sys_libs,
|
||||
|
|
Loading…
Reference in New Issue