G0: target component (components/esp32*) doesn't depend on driver anymore

This commit is contained in:
Omar Chebib
2022-01-28 19:47:04 +08:00
parent 6e0308d352
commit 2571aaf3c9
37 changed files with 74 additions and 42 deletions

View File

@@ -47,7 +47,8 @@ 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 soc # Requires "driver" for GPTimer in "SEGGER_SYSVIEW_Config_FreeRTOS.c"
PRIV_REQUIRES soc driver
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)
# disable --coverage for this component, as it is used as transport # disable --coverage for this component, as it is used as transport

View File

@@ -1,4 +1,4 @@
idf_component_register(SRC_DIRS "." idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "." PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES cmock test_utils app_update bootloader_support nvs_flash PRIV_REQUIRES cmock test_utils app_update bootloader_support nvs_flash driver
) )

View File

@@ -1,3 +1,3 @@
idf_component_register(SRC_DIRS "." idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "." PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES cmock) PRIV_REQUIRES cmock driver)

View File

@@ -108,13 +108,18 @@ if(IDF_TARGET STREQUAL "esp32c2")
list(APPEND srcs "spi_slave_hd.c") list(APPEND srcs "spi_slave_hd.c")
endif() endif()
idf_component_register(SRCS "${srcs}" if(BOOTLOADER_BUILD)
INCLUDE_DIRS ${includes} # Bootloader shall NOT depend on the drivers
PRIV_INCLUDE_DIRS "include/driver" idf_component_register()
PRIV_REQUIRES efuse esp_timer else()
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support # (REQUIRES cannot hide soc headers, since many arguments in the driver headers are chip-dependent)
LDFRAGMENTS linker.lf) idf_component_register(SRCS "${srcs}"
# (REQUIRES cannot hide soc headers, since many arguments in the driver headers are chip-dependent) INCLUDE_DIRS ${includes}
PRIV_INCLUDE_DIRS "include/driver"
PRIV_REQUIRES efuse esp_timer
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
LDFRAGMENTS linker.lf)
endif()
# uses C11 atomic feature # uses C11 atomic feature
set_source_files_properties(spi_master.c PROPERTIES COMPILE_FLAGS -std=gnu11) set_source_files_properties(spi_master.c PROPERTIES COMPILE_FLAGS -std=gnu11)

View File

@@ -6,7 +6,7 @@ endif()
if(NOT BOOTLOADER_BUILD) if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility # [refactor-todo] propagate these requirements for compatibility
# remove in the future # remove in the future
set(legacy_reqs driver efuse soc) set(legacy_reqs efuse soc)
endif() endif()
idf_component_register(REQUIRES xtensa "${legacy_reqs}" idf_component_register(REQUIRES xtensa "${legacy_reqs}"

View File

@@ -6,7 +6,7 @@ endif()
if(NOT BOOTLOADER_BUILD) if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility # [refactor-todo] propagate these requirements for compatibility
# remove in the future # remove in the future
set(legacy_reqs driver efuse soc) set(legacy_reqs efuse soc)
endif() endif()
idf_component_register(REQUIRES riscv "${legacy_reqs}" idf_component_register(REQUIRES riscv "${legacy_reqs}"

View File

@@ -6,7 +6,7 @@ endif()
if(NOT BOOTLOADER_BUILD) if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility # [refactor-todo] propagate these requirements for compatibility
# remove in the future # remove in the future
set(legacy_reqs driver efuse soc) set(legacy_reqs efuse soc)
endif() endif()
idf_component_register(REQUIRES riscv "${legacy_reqs}" idf_component_register(REQUIRES riscv "${legacy_reqs}"

View File

@@ -6,7 +6,7 @@ endif()
if(NOT BOOTLOADER_BUILD) if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility # [refactor-todo] propagate these requirements for compatibility
# remove in the future # remove in the future
set(legacy_reqs driver efuse soc) set(legacy_reqs efuse soc)
endif() endif()
idf_component_register(REQUIRES riscv "${legacy_reqs}" idf_component_register(REQUIRES riscv "${legacy_reqs}"

View File

@@ -6,7 +6,7 @@ endif()
if(NOT BOOTLOADER_BUILD) if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility # [refactor-todo] propagate these requirements for compatibility
# remove in the future # remove in the future
set(legacy_reqs driver efuse soc) set(legacy_reqs efuse soc)
endif() endif()
idf_component_register(REQUIRES xtensa "${legacy_reqs}" idf_component_register(REQUIRES xtensa "${legacy_reqs}"

View File

@@ -6,7 +6,7 @@ endif()
if(NOT BOOTLOADER_BUILD) if(NOT BOOTLOADER_BUILD)
# [refactor-todo] propagate these requirements for compatibility # [refactor-todo] propagate these requirements for compatibility
# remove in the future # remove in the future
set(legacy_reqs driver efuse soc) set(legacy_reqs efuse soc)
endif() endif()
idf_component_register(REQUIRES xtensa "${legacy_reqs}" idf_component_register(REQUIRES xtensa "${legacy_reqs}"

View File

@@ -2,13 +2,15 @@ idf_build_get_property(components_to_build BUILD_COMPONENTS)
set(srcs) set(srcs)
set(include) set(include)
set(priv_requires) # As CONFIG_ETH_ENABLED comes from Kconfig, it is not evaluated yet
# when components are being registered.
# Thus, always add the (private) requirements, regardless of Kconfig
set(priv_requires driver log esp_timer)
# If Ethernet disabled in Kconfig, this is a config-only component # If Ethernet disabled in Kconfig, this is a config-only component
if(CONFIG_ETH_ENABLED) if(CONFIG_ETH_ENABLED)
set(srcs "src/esp_eth.c" "src/esp_eth_phy.c") set(srcs "src/esp_eth.c" "src/esp_eth_phy.c")
set(include "include") set(include "include")
set(priv_requires "driver" "log" "esp_timer") # require "driver" for using some GPIO APIs
if(NOT CMAKE_BUILD_EARLY_EXPANSION) if(NOT CMAKE_BUILD_EARLY_EXPANSION)
# esp_netif related # esp_netif related

View File

@@ -18,6 +18,10 @@ if(NOT BOOTLOADER_BUILD)
if(NOT CONFIG_IDF_TARGET_ESP32 AND NOT CONFIG_IDF_TARGET_ESP32S2) if(NOT CONFIG_IDF_TARGET_ESP32 AND NOT CONFIG_IDF_TARGET_ESP32S2)
list(APPEND srcs "sleep_retention.c") list(APPEND srcs "sleep_retention.c")
endif() endif()
# [refactor-todo]: requires "driver" for GPIO and RTC (by sleep_gpio and sleep_modes)
list(APPEND priv_requires driver)
else() else()
# Requires "_esp_error_check_failed()" function # Requires "_esp_error_check_failed()" function
list(APPEND priv_requires "esp_system") list(APPEND priv_requires "esp_system")

View File

@@ -2,6 +2,6 @@ set(srcs "test_app_main.c"
"test_i2c_lcd_panel.c") "test_i2c_lcd_panel.c")
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES esp_lcd unity) PRIV_REQUIRES esp_lcd unity driver)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u test_app_include_i2c_lcd") target_link_libraries(${COMPONENT_LIB} INTERFACE "-u test_app_include_i2c_lcd")

View File

@@ -2,6 +2,6 @@ set(srcs "test_app_main.c"
"test_i80_lcd_panel.c") "test_i80_lcd_panel.c")
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES esp_lcd unity) PRIV_REQUIRES esp_lcd unity driver)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u test_app_include_i80_lcd") target_link_libraries(${COMPONENT_LIB} INTERFACE "-u test_app_include_i80_lcd")

View File

@@ -2,6 +2,6 @@ set(srcs "test_app_main.c"
"test_spi_lcd_panel.c") "test_spi_lcd_panel.c")
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES esp_lcd unity) PRIV_REQUIRES esp_lcd unity driver)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u test_app_include_spi_lcd") target_link_libraries(${COMPONENT_LIB} INTERFACE "-u test_app_include_spi_lcd")

View File

@@ -1,3 +1,3 @@
idf_component_register(SRC_DIRS "." idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "../private_include" "." PRIV_INCLUDE_DIRS "../private_include" "."
PRIV_REQUIRES cmock test_utils esp_netif nvs_flash) PRIV_REQUIRES cmock test_utils esp_netif nvs_flash driver)

View File

@@ -28,17 +28,18 @@ if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN)
endif() endif()
endif() endif()
# [refactor-todo]: requires "driver" component for periph_ctrl header file
if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED) if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED)
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 PRIV_REQUIRES nvs_flash driver
LDFRAGMENTS "${ldfragments}" LDFRAGMENTS "${ldfragments}"
EMBED_FILES "${build_dir}/phy_multiple_init_data.bin" EMBED_FILES "${build_dir}/phy_multiple_init_data.bin"
) )
else() else()
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 PRIV_REQUIRES nvs_flash driver
LDFRAGMENTS "${ldfragments}" LDFRAGMENTS "${ldfragments}"
) )
endif() endif()

View File

@@ -1,2 +1,2 @@
idf_component_register(SRC_DIRS . idf_component_register(SRC_DIRS .
PRIV_REQUIRES unity esp_pm ulp) PRIV_REQUIRES unity esp_pm ulp driver)

View File

@@ -41,7 +41,11 @@ else()
# should be removable once using component init functions # should be removable once using component init functions
# link-time registration is used. # link-time registration is used.
esp_pm app_update nvs_flash pthread esp_pm app_update nvs_flash pthread
esp_phy efuse # [refactor-todo] requires "driver" for headers:
# - periph_ctrl.h
# - rtc_cntl.h
# - spi_common_internal.h
esp_phy efuse driver
LDFRAGMENTS "linker.lf" "app.lf") LDFRAGMENTS "linker.lf" "app.lf")
add_subdirectory(port) add_subdirectory(port)

View File

@@ -76,7 +76,7 @@ endif() # CONFIG_TINYUSB
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes_public} INCLUDE_DIRS ${includes_public}
PRIV_INCLUDE_DIRS ${includes_private} PRIV_INCLUDE_DIRS ${includes_private}
PRIV_REQUIRES "vfs" "usb" PRIV_REQUIRES "vfs" "usb" "driver"
) )
if(CONFIG_TINYUSB) if(CONFIG_TINYUSB)

View File

@@ -1,7 +1,11 @@
set(srcs) set(srcs)
set(include) set(include)
set(priv_include) set(priv_include)
set(priv_require) # As CONFIG_USB_OTG_SUPPORTED comes from Kconfig, it is not evaluated yet
# when components are being registered.
# Thus, always add the (private) requirements, regardless of Kconfig
# [refactor-todo]: requires "driver" because "periph_ctrl.h" is used in "hcd.c"
set(priv_require hal driver)
if(CONFIG_USB_OTG_SUPPORTED) if(CONFIG_USB_OTG_SUPPORTED)
list(APPEND srcs "hcd.c" list(APPEND srcs "hcd.c"
@@ -13,7 +17,6 @@ if(CONFIG_USB_OTG_SUPPORTED)
"usb_phy.c") "usb_phy.c")
list(APPEND include "include") list(APPEND include "include")
list(APPEND priv_include "private_include") list(APPEND priv_include "private_include")
list(APPEND priv_require "hal" "driver")
endif() endif()
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}

View File

@@ -627,6 +627,8 @@ Main component requirements
The component named ``main`` is special because it automatically requires all other components in the build. So it's not necessary to pass ``REQUIRES`` or ``PRIV_REQUIRES`` to this component. See :ref:`renaming main <rename-main>` for a description of what needs to be changed if no longer using the ``main`` component. The component named ``main`` is special because it automatically requires all other components in the build. So it's not necessary to pass ``REQUIRES`` or ``PRIV_REQUIRES`` to this component. See :ref:`renaming main <rename-main>` for a description of what needs to be changed if no longer using the ``main`` component.
.. _component-common-requirements:
Common component requirements Common component requirements
----------------------------- -----------------------------

View File

@@ -10,3 +10,8 @@ Update fragment file grammar
---------------------------- ----------------------------
Please follow the :ref:`migrate linker script fragment files grammar<ldgen-migrate-lf-grammar>` chapter for migrating v3.x grammar to the new one. Please follow the :ref:`migrate linker script fragment files grammar<ldgen-migrate-lf-grammar>` chapter for migrating v3.x grammar to the new one.
Dependency on driver component shall be explicit
------------------------------------------------
In previous versions of ESP-IDF, target components (``components/esp32*``) had a dependency on ``driver`` component. Since target components were part of common requirements (:ref:`more info about common requirements <component-common-requirements>`), all components in the project implicitly had a dependency on ``driver`` component. Now that the dependency of target components on ``driver`` has been removed, every component which depends on ``driver`` has to declare this dependency explicitly. This can be done by adding ``REQUIRES driver`` or ``PRIV_REQUIRES driver`` in ``idf_component_register`` call inside component's ``CMakeLists.txt``. See :ref:`Component Requirements` for more information on specifying component requirements.

View File

@@ -627,6 +627,8 @@ Spark Plug 组件
``main`` 组件比较特别,因为它在构建过程中自动依赖所有其他组件。所以不需要向这个组件传递 ``REQUIRES````PRIV_REQUIRES``。有关不再使用 ``main`` 组件时需要更改哪些内容,请参考 :ref:`重命名 main 组件<rename-main>` ``main`` 组件比较特别,因为它在构建过程中自动依赖所有其他组件。所以不需要向这个组件传递 ``REQUIRES````PRIV_REQUIRES``。有关不再使用 ``main`` 组件时需要更改哪些内容,请参考 :ref:`重命名 main 组件<rename-main>`
.. _component-common-requirements:
通用组件依赖项 通用组件依赖项
-------------- --------------

View File

@@ -1,2 +1,3 @@
idf_component_register(SRCS "button.c" "button_obj.cpp" idf_component_register(SRCS "button.c" "button_obj.cpp"
INCLUDE_DIRS "." "include") INCLUDE_DIRS "." "include"
PRIV_REQUIRES driver)

View File

@@ -5,6 +5,6 @@ set(COMPONENT_SRCS "light_driver.c"
set(COMPONENT_ADD_INCLUDEDIRS ". include") set(COMPONENT_ADD_INCLUDEDIRS ". include")
# requirements can't depend on config # requirements can't depend on config
set(COMPONENT_REQUIRES example_nvs) set(COMPONENT_REQUIRES example_nvs driver)
register_component() register_component()

View File

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

View File

@@ -1,4 +1,4 @@
idf_component_register(SRCS "connect.c" "stdin_out.c" "addr_from_stdin.c" idf_component_register(SRCS "connect.c" "stdin_out.c" "addr_from_stdin.c"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_REQUIRES esp_netif PRIV_REQUIRES esp_netif driver
) )

View File

@@ -1,3 +1,4 @@
idf_component_register(SRCS "esp_eth_mac_enc28j60.c" idf_component_register(SRCS "esp_eth_mac_enc28j60.c"
"esp_eth_phy_enc28j60.c" "esp_eth_phy_enc28j60.c"
PRIV_REQUIRES driver
INCLUDE_DIRS ".") INCLUDE_DIRS ".")

View File

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

View File

@@ -1,2 +1,3 @@
idf_component_register(SRCS "musical_buzzer_example_main.c" idf_component_register(SRCS "musical_buzzer_example_main.c"
PRIV_REQUIRES musical_buzzer driver
INCLUDE_DIRS ".") INCLUDE_DIRS ".")

View File

@@ -1,3 +1,4 @@
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)

View File

@@ -3,5 +3,5 @@
idf_component_register( idf_component_register(
SRCS "library/slip_modem.c" SRCS "library/slip_modem.c"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
REQUIRES esp_netif REQUIRES esp_netif driver
) )

View File

@@ -3,5 +3,5 @@
idf_component_register( idf_component_register(
SRCS "slip_client_main.c" SRCS "slip_client_main.c"
INCLUDE_DIRS "." INCLUDE_DIRS "."
REQUIRES esp_netif slip_modem REQUIRES esp_netif slip_modem driver
) )

View File

@@ -1,3 +1,3 @@
idf_component_register(SRCS "cmd_system.c" idf_component_register(SRCS "cmd_system.c"
INCLUDE_DIRS . INCLUDE_DIRS .
REQUIRES console spi_flash) REQUIRES console spi_flash driver)

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 soc nvs_flash ulp) REQUIRES driver soc nvs_flash ulp)
# #
# ULP support additions to component CMakeLists.txt. # ULP support additions to component CMakeLists.txt.
# #

View File

@@ -1,3 +1,3 @@
idf_component_register(SRCS "usb_test_main.c" idf_component_register(SRCS "usb_test_main.c"
INCLUDE_DIRS "" INCLUDE_DIRS ""
REQUIRES unity) REQUIRES unity driver usb)