fix(build): clean up dependencies on driver component

This commit is contained in:
Ivan Grokhotkov
2024-09-15 11:22:51 +02:00
parent 5e056de1e7
commit 68e9bcbf1e
30 changed files with 41 additions and 55 deletions

View File

@@ -121,16 +121,3 @@ if(CONFIG_APPTRACE_GCOV_ENABLE)
else() else()
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${app_trace}> c) target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${app_trace}> c)
endif() endif()
# This function adds a dependency on the given component if the component is included into the build.
function(maybe_add_component component_name)
idf_build_get_property(components BUILD_COMPONENTS)
if(${component_name} IN_LIST components)
idf_component_get_property(lib_name ${component_name} COMPONENT_LIB)
target_link_libraries(${COMPONENT_LIB} PUBLIC ${lib_name})
endif()
endfunction()
if(CONFIG_APPTRACE_DEST_UART0 OR CONFIG_APPTRACE_DEST_UART1 OR CONFIG_APPTRACE_DEST_UART2)
maybe_add_component(driver)
endif()

View File

@@ -51,7 +51,18 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/deprecated/${target}/esp_adc_cal_legacy.c
list(APPEND srcs "deprecated/${target}/esp_adc_cal_legacy.c") list(APPEND srcs "deprecated/${target}/esp_adc_cal_legacy.c")
endif() endif()
set(extra_requires)
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "esp32")
list(APPEND extra_requires esp_driver_i2s)
endif()
if(${target} STREQUAL "esp32s2")
list(APPEND extra_requires esp_driver_spi)
endif()
list(APPEND extra_requires driver) # esp_adc depends on "driver/adc_types_legacy.h"
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes} INCLUDE_DIRS ${includes}
PRIV_REQUIRES driver esp_driver_gpio efuse esp_pm esp_ringbuf esp_mm PRIV_REQUIRES esp_driver_gpio efuse esp_pm esp_ringbuf esp_mm ${extra_requires}
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)

View File

@@ -27,7 +27,7 @@ endif()
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_REQUIRES esp_timer driver esp_event PRIV_REQUIRES esp_timer esp_driver_gpio
LDFRAGMENTS "${ldfragments}") LDFRAGMENTS "${ldfragments}")
if(CONFIG_ESP_COEX_ENABLED) if(CONFIG_ESP_COEX_ENABLED)

View File

@@ -53,10 +53,9 @@ if(CONFIG_ESP_PHY_ENABLED)
endif() endif()
endif() endif()
# [refactor-todo]: requires "driver" component for periph_ctrl header file
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include" "${idf_target}/include" INCLUDE_DIRS "include" "${idf_target}/include"
PRIV_REQUIRES nvs_flash driver efuse esp_timer esp_wifi PRIV_REQUIRES nvs_flash esp_driver_gpio efuse esp_timer esp_wifi
LDFRAGMENTS "${ldfragments}" LDFRAGMENTS "${ldfragments}"
EMBED_FILES ${embed_files} EMBED_FILES ${embed_files}
) )

View File

@@ -8,9 +8,7 @@ set(includes "include")
set(priv_requires heap spi_flash esp_mm) set(priv_requires heap spi_flash esp_mm)
if(${target} STREQUAL "esp32") if(${target} STREQUAL "esp32")
list(APPEND priv_requires bootloader_support) list(APPEND priv_requires bootloader_support esp_driver_spi esp_driver_gpio)
# [refactor-todo]: requires "driver" for `spicommon_periph_claim`
list(APPEND priv_requires driver)
endif() endif()
set(srcs) set(srcs)

View File

@@ -14,13 +14,6 @@ if(CONFIG_ESP_WIFI_ENABLED OR CONFIG_ESP_HOST_WIFI_ENABLED)
set(ldfragments "linker.lf") set(ldfragments "linker.lf")
endif() endif()
if(IDF_TARGET_ESP32)
# dport workaround headers are in esp32 component
set(extra_priv_requires esp32)
else()
set(extra_priv_requires)
endif()
set(srcs set(srcs
"src/lib_printf.c" "src/lib_printf.c"
"src/mesh_event.c" "src/mesh_event.c"
@@ -57,8 +50,8 @@ idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include" "wifi_apps/include" "wifi_apps/nan_app/include" ${local_include_dirs} INCLUDE_DIRS "include" "wifi_apps/include" "wifi_apps/nan_app/include" ${local_include_dirs}
REQUIRES esp_event esp_phy esp_netif REQUIRES esp_event esp_phy esp_netif
PRIV_REQUIRES driver esptool_py esp_pm esp_timer nvs_flash PRIV_REQUIRES esptool_py esp_pm esp_timer nvs_flash
wpa_supplicant hal lwip esp_coex ${extra_priv_requires} wpa_supplicant hal lwip esp_coex
PRIV_INCLUDE_DIRS ../wpa_supplicant/src/ ../wpa_supplicant/esp_supplicant/src/ PRIV_INCLUDE_DIRS ../wpa_supplicant/src/ ../wpa_supplicant/esp_supplicant/src/
wifi_apps/roaming_app/include wifi_apps/roaming_app/include
LDFRAGMENTS "${ldfragments}") LDFRAGMENTS "${ldfragments}")

View File

@@ -34,8 +34,6 @@ idf_component_register(SRCS ${srcs}
LDFRAGMENTS linker.lf LDFRAGMENTS linker.lf
PRIV_REQUIRES esp_partition spi_flash bootloader_support mbedtls esp_rom soc esp_system PRIV_REQUIRES esp_partition spi_flash bootloader_support mbedtls esp_rom soc esp_system
esp_driver_gpio esp_driver_gpio
# [refactor-todo] esp_flash_internal.h -> spi_common_internal.h requires cleanup
driver
) )
# make sure 'core_dump_init' object file is considered by the linker # make sure 'core_dump_init' object file is considered by the linker

View File

@@ -35,5 +35,5 @@ idf_component_register(
INCLUDE_DIRS "${include}" INCLUDE_DIRS "${include}"
PRIV_INCLUDE_DIRS "${private_include}" PRIV_INCLUDE_DIRS "${private_include}"
LDFRAGMENTS linker.lf LDFRAGMENTS linker.lf
PRIV_REQUIRES esp_phy driver esp_timer esp_coex soc hal PRIV_REQUIRES esp_phy esp_timer esp_coex soc hal esp_pm
) )

View File

@@ -54,5 +54,5 @@ endif()
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}" INCLUDE_DIRS "${include_dirs}"
PRIV_INCLUDE_DIRS "${priv_include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}"
PRIV_REQUIRES protobuf-c mbedtls console esp_http_server driver PRIV_REQUIRES protobuf-c mbedtls console esp_http_server esp_driver_uart
REQUIRES bt) REQUIRES bt)

View File

@@ -6,12 +6,12 @@ endif()
set(TOUCH_ELEMENT_COMPATIBLE_TARGETS "esp32s2" "esp32s3") set(TOUCH_ELEMENT_COMPATIBLE_TARGETS "esp32s2" "esp32s3")
if(IDF_TARGET IN_LIST TOUCH_ELEMENT_COMPATIBLE_TARGETS) if(${target} IN_LIST TOUCH_ELEMENT_COMPATIBLE_TARGETS)
idf_component_register(SRCS "touch_element.c" idf_component_register(SRCS "touch_element.c"
"touch_button.c" "touch_button.c"
"touch_slider.c" "touch_slider.c"
"touch_matrix.c" "touch_matrix.c"
INCLUDE_DIRS include INCLUDE_DIRS include
REQUIRES driver REQUIRES driver # touch_element uses legacy "driver/touch_sensor.h"
PRIV_REQUIRES esp_timer) PRIV_REQUIRES esp_timer)
endif() endif()

View File

@@ -1,3 +1,3 @@
idf_component_register(SRCS "misc.c" "scli.c" idf_component_register(SRCS "misc.c" "scli.c"
INCLUDE_DIRS "." INCLUDE_DIRS "."
PRIV_REQUIRES bt console driver) PRIV_REQUIRES bt console esp_driver_uart)

View File

@@ -1,4 +1,4 @@
idf_component_register(SRCS "cmd_system.c" idf_component_register(SRCS "cmd_system.c"
INCLUDE_DIRS "." INCLUDE_DIRS "."
PRIV_REQUIRES driver PRIV_REQUIRES esp_driver_uart esp_driver_gpio
REQUIRES console spi_flash) REQUIRES console spi_flash)

View File

@@ -29,7 +29,7 @@ endif()
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_REQUIRES esp_netif driver esp_wifi vfs console esp_eth) PRIV_REQUIRES esp_netif esp_driver_gpio esp_driver_uart esp_wifi vfs console esp_eth)
if(CONFIG_EXAMPLE_PROVIDE_WIFI_CONSOLE_CMD) if(CONFIG_EXAMPLE_PROVIDE_WIFI_CONSOLE_CMD)
idf_component_optional_requires(PRIVATE console) idf_component_optional_requires(PRIVATE console)

View File

@@ -1,4 +1,4 @@
idf_component_register(SRCS "soft_i2c_master.c" idf_component_register(SRCS "soft_i2c_master.c"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_REQUIRES driver PRIV_REQUIRES esp_driver_gpio
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)

View File

@@ -2,4 +2,4 @@ set(srcs "soft_i2c_master_main.c")
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "." INCLUDE_DIRS "."
PRIV_REQUIRES driver soft_i2c_master) PRIV_REQUIRES soft_i2c_master)

View File

@@ -9,5 +9,5 @@ endif()
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_REQUIRES driver PRIV_REQUIRES esp_driver_gpio
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)

View File

@@ -15,5 +15,5 @@ endif()
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_REQUIRES driver PRIV_REQUIRES esp_driver_gpio
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)

View File

@@ -2,4 +2,4 @@ set(srcs "soft_uart_main.c")
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "." INCLUDE_DIRS "."
PRIV_REQUIRES driver soft_uart) PRIV_REQUIRES soft_uart)

View File

@@ -3,5 +3,5 @@ set(component_srcs "src/matrix_keyboard.c")
idf_component_register(SRCS "${component_srcs}" idf_component_register(SRCS "${component_srcs}"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "" PRIV_INCLUDE_DIRS ""
PRIV_REQUIRES "driver" PRIV_REQUIRES "esp_driver_gpio"
REQUIRES "") REQUIRES "")

View File

@@ -1,3 +1,3 @@
idf_component_register(SRCS "i2c_eeprom.c" idf_component_register(SRCS "i2c_eeprom.c"
INCLUDE_DIRS "." INCLUDE_DIRS "."
PRIV_REQUIRES driver) PRIV_REQUIRES esp_driver_i2c)

View File

@@ -1,5 +1,5 @@
idf_component_register( idf_component_register(
SRCS app_main.c svpwm/esp_svpwm.c foc/esp_foc.c SRCS app_main.c svpwm/esp_svpwm.c foc/esp_foc.c
INCLUDE_DIRS "svpwm" "foc" INCLUDE_DIRS "svpwm" "foc"
REQUIRES driver PRIV_REQUIRES esp_driver_mcpwm esp_driver_gpio
) )

View File

@@ -1,4 +1,5 @@
idf_component_register(SRCS "spi_eeprom.c" idf_component_register(SRCS "spi_eeprom.c"
LDFRAGMENTS "linker.lf" LDFRAGMENTS "linker.lf"
INCLUDE_DIRS "." INCLUDE_DIRS "."
PRIV_REQUIRES driver) PRIV_REQUIRES esp_driver_gpio
REQUIRES esp_driver_spi)

View File

@@ -2,6 +2,5 @@
# in this exact order for cmake to work correctly # in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
# external SPI flash driver not currently supported for ESP32-S2
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(fatfs_ext_flash) project(fatfs_ext_flash)

View File

@@ -1,6 +1,6 @@
idf_component_register(SRCS "cmd_system.c" "cmd_system_common.c" idf_component_register(SRCS "cmd_system.c" "cmd_system_common.c"
INCLUDE_DIRS . INCLUDE_DIRS .
REQUIRES console spi_flash driver esp_driver_gpio) REQUIRES console spi_flash esp_driver_uart esp_driver_gpio)
if(CONFIG_SOC_DEEP_SLEEP_SUPPORTED OR CONFIG_SOC_LIGHT_SLEEP_SUPPORTED) if(CONFIG_SOC_DEEP_SLEEP_SUPPORTED OR CONFIG_SOC_LIGHT_SLEEP_SUPPORTED)
target_sources(${COMPONENT_LIB} PRIVATE cmd_system_sleep.c) target_sources(${COMPONENT_LIB} PRIVATE cmd_system_sleep.c)

View File

@@ -1,6 +1,6 @@
idf_component_register(SRCS "ulp_example_main.c" idf_component_register(SRCS "ulp_example_main.c"
INCLUDE_DIRS "" INCLUDE_DIRS ""
REQUIRES driver soc nvs_flash ulp) REQUIRES esp_driver_gpio soc nvs_flash ulp)
# #
# ULP support additions to component CMakeLists.txt. # ULP support additions to component CMakeLists.txt.
# #

View File

@@ -1,6 +1,6 @@
idf_component_register(SRCS "ulp_adc_example_main.c" idf_component_register(SRCS "ulp_adc_example_main.c"
INCLUDE_DIRS "" INCLUDE_DIRS ""
REQUIRES soc nvs_flash ulp driver esp_adc) REQUIRES soc nvs_flash ulp esp_driver_gpio esp_adc)
# #
# ULP support additions to component CMakeLists.txt. # ULP support additions to component CMakeLists.txt.
# #

View File

@@ -1,7 +1,7 @@
# Set usual component variables # Set usual component variables
set(COMPONENT_SRCS "ulp_riscv_ds18b20_example_main.c") set(COMPONENT_SRCS "ulp_riscv_ds18b20_example_main.c")
set(COMPONENT_ADD_INCLUDEDIRS "") set(COMPONENT_ADD_INCLUDEDIRS "")
set(COMPONENT_REQUIRES soc nvs_flash ulp driver) set(COMPONENT_REQUIRES soc nvs_flash ulp esp_driver_gpio)
register_component() register_component()

View File

@@ -1,7 +1,7 @@
# Set usual component variables # Set usual component variables
set(COMPONENT_SRCS "ulp_riscv_example_main.c") set(COMPONENT_SRCS "ulp_riscv_example_main.c")
set(COMPONENT_ADD_INCLUDEDIRS "") set(COMPONENT_ADD_INCLUDEDIRS "")
set(COMPONENT_REQUIRES soc nvs_flash ulp driver) set(COMPONENT_REQUIRES soc nvs_flash ulp esp_driver_gpio)
register_component() register_component()

View File

@@ -1,7 +1,7 @@
# Set usual component variables # Set usual component variables
set(COMPONENT_SRCS "ulp_riscv_gpio_intr_example_main.c") set(COMPONENT_SRCS "ulp_riscv_gpio_intr_example_main.c")
set(COMPONENT_ADD_INCLUDEDIRS "") set(COMPONENT_ADD_INCLUDEDIRS "")
set(COMPONENT_REQUIRES ulp driver) set(COMPONENT_REQUIRES ulp esp_driver_gpio)
register_component() register_component()

View File

@@ -1,7 +1,7 @@
# Set usual component variables # Set usual component variables
set(COMPONENT_SRCS "ulp_riscv_example_main.c") set(COMPONENT_SRCS "ulp_riscv_example_main.c")
set(COMPONENT_ADD_INCLUDEDIRS "") set(COMPONENT_ADD_INCLUDEDIRS "")
set(COMPONENT_REQUIRES soc nvs_flash ulp driver) set(COMPONENT_REQUIRES soc nvs_flash ulp)
register_component() register_component()