mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 13:44:32 +02:00
ulp: cmake: simplify the dependency on the generated LD script
* "dummy loop to force pre-processed linker file generation" seems to be unnecessary. It looks like the idea was copied from the dependency of ULP-FSM preprocessed source files on the LD script. * Can use add_dependencies instead of set_target_properties(...LINK_DEPENDS...) which is more readable * Use target_link_options instead of target_link_libraries, which is supported starting from CMake 3.13. Unlike target_link_libraries, it doesn't require manually quoting the pats.
This commit is contained in:
@@ -32,12 +32,6 @@ if(NOT ULP_COCPU_IS_RISCV)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ULP_COCPU_IS_RISCV)
|
|
||||||
set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_riscv.ld)
|
|
||||||
else()
|
|
||||||
set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_fsm.ld)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
set(ULP_MAP_GEN ${PYTHON} ${IDF_PATH}/components/ulp/esp32ulp_mapgen.py)
|
set(ULP_MAP_GEN ${PYTHON} ${IDF_PATH}/components/ulp/esp32ulp_mapgen.py)
|
||||||
get_filename_component(sdkconfig_dir ${SDKCONFIG_HEADER} DIRECTORY)
|
get_filename_component(sdkconfig_dir ${SDKCONFIG_HEADER} DIRECTORY)
|
||||||
@@ -54,16 +48,23 @@ target_include_directories(${ULP_APP_NAME} PRIVATE ${COMPONENT_INCLUDES})
|
|||||||
|
|
||||||
list(APPEND ULP_PREPROCESSOR_ARGS -D__ASSEMBLER__)
|
list(APPEND ULP_PREPROCESSOR_ARGS -D__ASSEMBLER__)
|
||||||
|
|
||||||
# Preprocess linker script, pre-linking
|
# Pre-process the linker script
|
||||||
|
if(ULP_COCPU_IS_RISCV)
|
||||||
|
set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_riscv.ld)
|
||||||
|
else()
|
||||||
|
set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_fsm.ld)
|
||||||
|
endif()
|
||||||
get_filename_component(ULP_LD_SCRIPT ${ULP_LD_TEMPLATE} NAME)
|
get_filename_component(ULP_LD_SCRIPT ${ULP_LD_TEMPLATE} NAME)
|
||||||
add_custom_command(OUTPUT ${ULP_LD_SCRIPT}
|
add_custom_command(OUTPUT ${ULP_LD_SCRIPT}
|
||||||
COMMAND ${CMAKE_C_COMPILER} -E -P -xc -o ${ULP_LD_SCRIPT} ${ULP_PREPROCESSOR_ARGS} ${ULP_LD_TEMPLATE}
|
COMMAND ${CMAKE_C_COMPILER} -E -P -xc -o ${ULP_LD_SCRIPT} ${ULP_PREPROCESSOR_ARGS} ${ULP_LD_TEMPLATE}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
DEPENDS ${ULP_LD_TEMPLATE} ${SDKCONFIG_HEADER}
|
MAIN_DEPENDENCY ${ULP_LD_TEMPLATE}
|
||||||
|
DEPENDS ${SDKCONFIG_HEADER}
|
||||||
|
COMMENT "Generating ${ULP_LD_SCRIPT} linker script..."
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
add_custom_target(${ULP_APP_NAME}_ld_script
|
add_custom_target(ld_script DEPENDS ${ULP_LD_SCRIPT})
|
||||||
DEPENDS ${ULP_LD_SCRIPT}
|
add_dependencies(${ULP_APP_NAME} ld_script)
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
target_link_options(${ULP_APP_NAME} PRIVATE SHELL:-T ${CMAKE_CURRENT_BINARY_DIR}/${ULP_LD_SCRIPT})
|
||||||
|
|
||||||
# To avoid warning "Manually-specified variables were not used by the project"
|
# To avoid warning "Manually-specified variables were not used by the project"
|
||||||
set(bypassWarning "${IDF_TARGET}")
|
set(bypassWarning "${IDF_TARGET}")
|
||||||
@@ -77,19 +78,6 @@ if(ULP_COCPU_IS_RISCV)
|
|||||||
"${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_print.c"
|
"${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_print.c"
|
||||||
"${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_utils.c")
|
"${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_utils.c")
|
||||||
|
|
||||||
#dummy loop to force pre-processed linker file generation:
|
|
||||||
foreach(ulp_s_source ${ULP_S_SOURCES})
|
|
||||||
set(noop ${ulp_s_source})
|
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${noop}
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
COMMAND cmake -E echo
|
|
||||||
DEPENDS ${ULP_LD_SCRIPT}
|
|
||||||
)
|
|
||||||
|
|
||||||
set_source_files_properties(${noop} PROPERTIES NOOP_PROPERTY ${ULP_LD_SCRIPT})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set(DUMP_SYMBOL_ARGS -g)
|
set(DUMP_SYMBOL_ARGS -g)
|
||||||
set(MAP_GEN_EXTRA_ARGS --riscv)
|
set(MAP_GEN_EXTRA_ARGS --riscv)
|
||||||
target_link_options(${ULP_APP_NAME} PRIVATE "-nostartfiles")
|
target_link_options(${ULP_APP_NAME} PRIVATE "-nostartfiles")
|
||||||
@@ -112,7 +100,7 @@ else()
|
|||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
COMMAND ${CMAKE_C_COMPILER} -E -P -xc ${ULP_PREPROCESSOR_ARGS}
|
COMMAND ${CMAKE_C_COMPILER} -E -P -xc ${ULP_PREPROCESSOR_ARGS}
|
||||||
-o ${ulp_ps_output} ${ulp_s_source}
|
-o ${ulp_ps_output} ${ulp_s_source}
|
||||||
DEPENDS ${ulp_s_source} ${ULP_LD_SCRIPT}
|
DEPENDS ${ulp_s_source}
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
# During assembly file compilation, output listing files as well.
|
# During assembly file compilation, output listing files as well.
|
||||||
set_source_files_properties(${ulp_ps_output}
|
set_source_files_properties(${ulp_ps_output}
|
||||||
@@ -152,6 +140,3 @@ add_custom_target(build
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}.ld
|
${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}.ld
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}.h
|
${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}.h
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
target_link_libraries(${ULP_APP_NAME} "-T\"${CMAKE_CURRENT_BINARY_DIR}/${ULP_LD_SCRIPT}\"")
|
|
||||||
set_target_properties(${ULP_APP_NAME} PROPERTIES LINK_DEPENDS ${ULP_LD_SCRIPT})
|
|
||||||
|
Reference in New Issue
Block a user