mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_common: simplify component build script
This commit is contained in:
parent
813044c6db
commit
43f6c7a533
@ -1,56 +1,37 @@
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
|
||||
list(APPEND srcs "src/esp_err_to_name.c")
|
||||
|
||||
if(BOOTLOADER_BUILD)
|
||||
# For bootloader, all we need from esp_common is headers
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS include
|
||||
PRIV_REQUIRES soc)
|
||||
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-Wl,--gc-sections")
|
||||
else()
|
||||
# Regular app build
|
||||
list(APPEND srcs "src/esp_err_to_name.c")
|
||||
# Note: esp_ipc, esp_pm added as a public requirement to keep compatibility as to be located here.
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS include
|
||||
REQUIRES ${target})
|
||||
|
||||
# Note: esp_ipc, esp_pm added as a public requirement to keep compatibility as to be located here.
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS include
|
||||
REQUIRES ${target} espcoredump esp_timer esp_ipc esp_pm esp_hw_support
|
||||
PRIV_REQUIRES soc)
|
||||
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 4)
|
||||
|
||||
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_LIBRARIES "-Wl,--gc-sections")
|
||||
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-Wl,--gc-sections")
|
||||
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 4)
|
||||
# List of components needed for the error codes list
|
||||
set(optional_reqs ulp
|
||||
efuse
|
||||
esp_http_client
|
||||
esp_http_server
|
||||
bootloader_support
|
||||
nvs_flash
|
||||
esp_wifi
|
||||
app_update
|
||||
lwip
|
||||
spi_flash
|
||||
wpa_supplicant
|
||||
tcpip_adapter
|
||||
esp_serial_slave_link
|
||||
esp_netif
|
||||
soc
|
||||
esp-tls
|
||||
esp_https_ota)
|
||||
|
||||
# List of components needed for the error codes list
|
||||
set(optional_reqs ulp
|
||||
efuse
|
||||
esp_http_client
|
||||
esp_http_server
|
||||
bootloader_support
|
||||
nvs_flash
|
||||
esp_wifi
|
||||
app_update
|
||||
lwip
|
||||
spi_flash
|
||||
wpa_supplicant
|
||||
tcpip_adapter
|
||||
esp_serial_slave_link
|
||||
esp_netif
|
||||
soc
|
||||
esp-tls
|
||||
esp_https_ota)
|
||||
|
||||
idf_build_get_property(build_components BUILD_COMPONENTS)
|
||||
foreach(req ${optional_reqs})
|
||||
if(req IN_LIST build_components)
|
||||
idf_component_get_property(req_lib ${req} COMPONENT_LIB)
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE ${req_lib})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
endif()
|
||||
|
||||
if(CONFIG_IDF_ENV_FPGA)
|
||||
# Forces the linker to include fpga stubs from this component
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_common_include_fpga_overrides")
|
||||
endif()
|
||||
idf_build_get_property(build_components BUILD_COMPONENTS)
|
||||
foreach(req ${optional_reqs})
|
||||
if(req IN_LIST build_components)
|
||||
idf_component_get_property(req_lib ${req} COMPONENT_LIB)
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE ${req_lib})
|
||||
endif()
|
||||
endforeach()
|
||||
|
@ -1,64 +1,63 @@
|
||||
if(BOOTLOADER_BUILD)
|
||||
# Bootloader relies on some Kconfig options defined in esp_system.
|
||||
idf_component_register()
|
||||
return()
|
||||
endif()
|
||||
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
|
||||
# Remove when sleep is brought up on master for C3 TODO ESP32-C3 IDF-2571
|
||||
set(srcs "esp_err.c"
|
||||
"freertos_hooks.c"
|
||||
"intr_alloc.c"
|
||||
"int_wdt.c"
|
||||
"esp_async_memcpy.c"
|
||||
"panic.c"
|
||||
"system_api.c"
|
||||
"startup.c"
|
||||
"system_time.c"
|
||||
"stack_check.c"
|
||||
"sleep_modes.c"
|
||||
"task_wdt.c")
|
||||
|
||||
if(NOT (${target} STREQUAL "esp32c3") )
|
||||
list(APPEND srcs "dbg_stubs.c")
|
||||
endif()
|
||||
set(srcs)
|
||||
|
||||
if(CONFIG_IDF_ENV_FPGA)
|
||||
list(APPEND srcs "fpga_overrides.c")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS include
|
||||
PRIV_REQUIRES spi_flash
|
||||
# [refactor-todo] requirements due to init code,
|
||||
# should be removable once using component init functions
|
||||
# link-time registration is used.
|
||||
esp_pm app_update nvs_flash pthread app_trace esp_gdbstub esp_ipc
|
||||
espcoredump
|
||||
LDFRAGMENTS "linker.lf")
|
||||
add_subdirectory(port)
|
||||
if(BOOTLOADER_BUILD)
|
||||
# Bootloader relies on some Kconfig options defined in esp_system.
|
||||
idf_component_register(SRCS "${srcs}")
|
||||
else()
|
||||
list(APPEND srcs "esp_err.c"
|
||||
"freertos_hooks.c"
|
||||
"intr_alloc.c"
|
||||
"int_wdt.c"
|
||||
"esp_async_memcpy.c"
|
||||
"panic.c"
|
||||
"system_api.c"
|
||||
"startup.c"
|
||||
"system_time.c"
|
||||
"stack_check.c"
|
||||
"sleep_modes.c"
|
||||
"task_wdt.c")
|
||||
|
||||
if(NOT (${target} STREQUAL "esp32c3") )
|
||||
list(APPEND srcs "dbg_stubs.c")
|
||||
endif()
|
||||
|
||||
# After system initialization, `start_app` (and its other cores variant) is called.
|
||||
# This is provided by the user or from another component. Since we can't establish
|
||||
# dependency on what we don't know, force linker to not drop the symbol regardless
|
||||
# of link line order.
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app")
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS include
|
||||
PRIV_REQUIRES spi_flash
|
||||
# [refactor-todo] requirements due to init code,
|
||||
# should be removable once using component init functions
|
||||
# link-time registration is used.
|
||||
esp_pm app_update nvs_flash pthread app_trace esp_gdbstub esp_ipc
|
||||
espcoredump
|
||||
LDFRAGMENTS "linker.lf")
|
||||
add_subdirectory(port)
|
||||
|
||||
if(NOT CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app_other_cores")
|
||||
endif()
|
||||
# After system initialization, `start_app` (and its other cores variant) is called.
|
||||
# This is provided by the user or from another component. Since we can't establish
|
||||
# dependency on what we don't know, force linker to not drop the symbol regardless
|
||||
# of link line order.
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app")
|
||||
|
||||
# Disable stack protection in files which are involved in initialization of that feature
|
||||
set_source_files_properties(
|
||||
"startup.c" "stack_check.c"
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-fno-stack-protector)
|
||||
if(NOT CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app_other_cores")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
|
||||
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/sleep_modes.c" PROPERTIES
|
||||
COMPILE_FLAGS "-fno-jump-tables -fno-tree-switch-conversion")
|
||||
# Disable stack protection in files which are involved in initialization of that feature
|
||||
set_source_files_properties(
|
||||
"startup.c" "stack_check.c"
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-fno-stack-protector)
|
||||
|
||||
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
|
||||
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/sleep_modes.c" PROPERTIES
|
||||
COMPILE_FLAGS "-fno-jump-tables -fno-tree-switch-conversion")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_IDF_ENV_FPGA)
|
||||
|
@ -1,5 +1,12 @@
|
||||
ifdef IS_BOOTLOADER_BUILD
|
||||
|
||||
ifndef CONFIG_IDF_ENV_FPGA
|
||||
COMPONENT_CONFIG_ONLY := 1
|
||||
else
|
||||
COMPONENT_SRCDIRS := .
|
||||
COMPONENT_OBJS += fpga_overrides.o
|
||||
endif
|
||||
|
||||
else
|
||||
SOC_NAME := $(IDF_TARGET)
|
||||
|
||||
@ -8,6 +15,10 @@ COMPONENT_ADD_INCLUDEDIRS := include
|
||||
COMPONENT_PRIV_INCLUDEDIRS := port/include port
|
||||
COMPONENT_ADD_LDFRAGMENTS += linker.lf
|
||||
|
||||
ifndef CONFIG_IDF_ENV_FPGA
|
||||
COMPONENT_OBJEXCLUDE += fpga_overrides.o
|
||||
endif
|
||||
|
||||
include $(COMPONENT_PATH)/port/soc/$(SOC_NAME)/component.mk
|
||||
|
||||
# disable stack protection in files which are involved in initialization of that feature
|
||||
|
@ -112,10 +112,13 @@ function(__build_set_default_build_specifications)
|
||||
|
||||
list(APPEND cxx_compile_options "-std=gnu++11")
|
||||
|
||||
list(APPEND link_options "-Wl,--gc-sections")
|
||||
|
||||
idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
|
||||
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
|
||||
idf_build_set_property(LINK_OPTIONS "${link_options}" APPEND)
|
||||
endfunction()
|
||||
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user