mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-15 19:34:03 +00:00
components: update with build system changes
This commit is contained in:
@@ -3,9 +3,8 @@ require_idf_targets(esp32)
|
||||
if(BOOTLOADER_BUILD)
|
||||
# For bootloader, all we need from esp32 is headers
|
||||
set(COMPONENT_ADD_INCLUDEDIRS include)
|
||||
set(COMPONENT_REQUIRES ${IDF_COMPONENTS} soc) #unfortunately rom/uart uses SOC registers directly
|
||||
set(COMPONENT_SRCS )
|
||||
register_component()
|
||||
target_linker_script(${COMPONENT_LIB} "ld/esp32.peripherals.ld")
|
||||
else()
|
||||
# Regular app build
|
||||
|
||||
@@ -47,52 +46,42 @@ else()
|
||||
|
||||
register_component()
|
||||
|
||||
target_linker_script(${COMPONENT_TARGET} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
|
||||
target_linker_script(${COMPONENT_LIB} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
|
||||
|
||||
# Rely on user code to define app_main
|
||||
target_link_libraries(${COMPONENT_LIB} "-u app_main")
|
||||
|
||||
if(CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY)
|
||||
# This has to be linked before esp32.project.ld
|
||||
target_linker_script(${COMPONENT_TARGET} "ld/esp32.extram.bss.ld")
|
||||
target_linker_script(${COMPONENT_LIB} "ld/esp32.extram.bss.ld")
|
||||
endif()
|
||||
|
||||
if(IDF_PROJECT_EXECUTABLE)
|
||||
# Process the template file through the linker script generation mechanism, and use the output for linking the
|
||||
# final binary
|
||||
set(esp32_project_script "${CMAKE_CURRENT_BINARY_DIR}/esp32.project.ld")
|
||||
set(esp32_project_template "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.project.ld.in")
|
||||
# Process the template file through the linker script generation mechanism, and use the output for linking the
|
||||
# final binary
|
||||
target_linker_script(${COMPONENT_LIB} "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.project.ld.in" PROCESS)
|
||||
|
||||
ldgen_process_template(${esp32_project_template} ${esp32_project_script})
|
||||
|
||||
target_link_libraries(${COMPONENT_TARGET} "-T ${esp32_project_script}")
|
||||
|
||||
set_property(TARGET ${IDF_PROJECT_EXECUTABLE} APPEND PROPERTY LINK_DEPENDS ${esp32_project_script})
|
||||
endif()
|
||||
|
||||
target_linker_script(${COMPONENT_TARGET} "ld/esp32.peripherals.ld")
|
||||
|
||||
target_link_libraries(${COMPONENT_TARGET} gcc)
|
||||
target_link_libraries(${COMPONENT_TARGET} "-u call_user_start_cpu0")
|
||||
target_linker_script(${COMPONENT_LIB} "ld/esp32.peripherals.ld")
|
||||
target_link_libraries(${COMPONENT_LIB} gcc)
|
||||
target_link_libraries(${COMPONENT_LIB} "-u call_user_start_cpu0")
|
||||
|
||||
#ld_include_panic_highint_hdl is added as an undefined symbol because otherwise the
|
||||
#linker will ignore panic_highint_hdl.S as it has no other files depending on any
|
||||
#symbols in it.
|
||||
target_link_libraries(${COMPONENT_TARGET} "-u ld_include_panic_highint_hdl")
|
||||
target_link_libraries(${COMPONENT_LIB} "-u ld_include_panic_highint_hdl")
|
||||
|
||||
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
|
||||
get_filename_component(config_dir ${sdkconfig_header} DIRECTORY)
|
||||
# Preprocess esp32.ld linker script to include configuration, becomes esp32_out.ld
|
||||
set(LD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ld)
|
||||
add_custom_command(
|
||||
OUTPUT esp32_out.ld
|
||||
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${CONFIG_DIR} ${LD_DIR}/esp32.ld
|
||||
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${config_dir} ${LD_DIR}/esp32.ld
|
||||
MAIN_DEPENDENCY ${LD_DIR}/esp32.ld ${SDKCONFIG_H}
|
||||
COMMENT "Generating linker script..."
|
||||
VERBATIM)
|
||||
|
||||
add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld)
|
||||
add_dependencies(${COMPONENT_TARGET} esp32_linker_script)
|
||||
|
||||
# Enable dynamic esp_timer overflow value if building unit tests
|
||||
if(esp32_test IN_LIST BUILD_TEST_COMPONENTS)
|
||||
add_definitions(-DESP_TIMER_DYNAMIC_OVERFLOW_VAL)
|
||||
endif()
|
||||
add_dependencies(${COMPONENT_LIB} esp32_linker_script)
|
||||
|
||||
# disable stack protection in files which are involved in initialization of that feature
|
||||
set_source_files_properties(
|
||||
|
||||
@@ -3,6 +3,19 @@ if(CONFIG_SPIRAM_CACHE_WORKAROUND)
|
||||
# are not part of the ESP-IDF build system (for cases where a generic
|
||||
# non-IDF CMakeLists.txt file is imported into a component) don't depend
|
||||
# on the esp32 component so don't get the extra flag. This handles that case.
|
||||
add_compile_options(-mfix-esp32-psram-cache-issue)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-issue" APPEND)
|
||||
endif()
|
||||
|
||||
# Check toolchain is configured properly in cmake
|
||||
if(NOT ( ${CMAKE_SYSTEM_NAME} STREQUAL "Generic" AND ${CMAKE_C_COMPILER} MATCHES xtensa))
|
||||
message(FATAL_ERROR "Internal error, toolchain has not been set correctly by project "
|
||||
"(or an invalid CMakeCache.txt file has been generated somehow)")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Warn if the toolchain version doesn't match
|
||||
#
|
||||
# TODO: make these platform-specific for diff toolchains
|
||||
get_expected_ctng_version(expected_toolchain expected_gcc)
|
||||
gcc_version_check("${expected_gcc}")
|
||||
crosstool_version_check("${expected_toolchain}")
|
||||
@@ -7,9 +7,11 @@ register_component()
|
||||
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
|
||||
COMMAND xxd -i "logo.jpg" "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
|
||||
WORKING_DIRECTORY ${COMPONENT_PATH}
|
||||
WORKING_DIRECTORY ${COMPONENT_DIR}
|
||||
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg")
|
||||
|
||||
add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h")
|
||||
|
||||
add_dependencies(${COMPONENT_TARGET} esp32_test_logo)
|
||||
add_dependencies(${COMPONENT_LIB} esp32_test_logo)
|
||||
|
||||
idf_build_set_property(COMPILE_DEFINITIONS "-DESP_TIMER_DYNAMIC_OVERFLOW_VAL" APPEND)
|
||||
|
||||
Reference in New Issue
Block a user