From a94c74c26b5ca2205f8065e28064cf8bb5dee3b5 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Mon, 18 Jul 2022 10:25:14 +0530 Subject: [PATCH] mbedtls: remove dependency on driver component - keep `esp_pm` dependency conditional in mbedtls - refactor `bt` cmakelist to keep dependencies as private Related: IDF-1265 --- components/bt/CMakeLists.txt | 3 ++- components/bt/test/CMakeLists.txt | 2 +- components/espcoredump/CMakeLists.txt | 2 +- components/mbedtls/CMakeLists.txt | 6 ++++-- components/mbedtls/port/aes/dma/esp_aes.c | 2 ++ components/mbedtls/port/esp_bignum.c | 2 ++ components/protocomm/CMakeLists.txt | 2 +- components/protocomm/src/transports/protocomm_nimble.c | 1 - .../ble_mesh_coex_test/components/case/wifi_connect.c | 3 +-- examples/bluetooth/esp_hid_device/main/CMakeLists.txt | 3 ++- examples/bluetooth/esp_hid_host/main/CMakeLists.txt | 3 ++- 11 files changed, 18 insertions(+), 11 deletions(-) diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index ca63f58d00..eaf41f8e07 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -678,7 +678,8 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}" - REQUIRES nvs_flash soc esp_timer esp_pm esp_phy mbedtls + REQUIRES esp_timer + PRIV_REQUIRES nvs_flash soc esp_pm esp_phy mbedtls driver LDFRAGMENTS "linker.lf") if(CONFIG_BT_ENABLED) diff --git a/components/bt/test/CMakeLists.txt b/components/bt/test/CMakeLists.txt index 27fb94b6e6..b703c5d776 100644 --- a/components/bt/test/CMakeLists.txt +++ b/components/bt/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CONFIG_BT_ENABLED OR CMAKE_BUILD_EARLY_EXPANSION) idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock nvs_flash bt) + PRIV_REQUIRES cmock nvs_flash bt esp_ringbuf) endif() diff --git a/components/espcoredump/CMakeLists.txt b/components/espcoredump/CMakeLists.txt index b5cc82410c..7f936a1cb4 100644 --- a/components/espcoredump/CMakeLists.txt +++ b/components/espcoredump/CMakeLists.txt @@ -24,4 +24,4 @@ idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${includes} PRIV_INCLUDE_DIRS ${priv_includes} LDFRAGMENTS linker.lf - PRIV_REQUIRES spi_flash app_update mbedtls esp_rom soc) + PRIV_REQUIRES spi_flash app_update mbedtls esp_rom soc driver) diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index b43fc52c04..51d6331978 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -254,8 +254,10 @@ if(CONFIG_MBEDTLS_DYNAMIC_BUFFER) endif() set_property(TARGET mbedcrypto APPEND PROPERTY LINK_INTERFACE_LIBRARIES mbedtls) -set_property(TARGET mbedcrypto APPEND PROPERTY LINK_LIBRARIES idf::driver) -set_property(TARGET mbedcrypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES idf::driver) + +if(CONFIG_PM_ENABLE) + target_link_libraries(mbedcrypto PRIVATE idf::esp_pm) +endif() target_link_libraries(${COMPONENT_LIB} ${linkage_type} ${mbedtls_targets}) diff --git a/components/mbedtls/port/aes/dma/esp_aes.c b/components/mbedtls/port/aes/dma/esp_aes.c index af614f7673..e899bee1da 100644 --- a/components/mbedtls/port/aes/dma/esp_aes.c +++ b/components/mbedtls/port/aes/dma/esp_aes.c @@ -35,7 +35,9 @@ #include "soc/lldesc.h" #include "esp_heap_caps.h" #include "sys/param.h" +#if CONFIG_PM_ENABLE #include "esp_pm.h" +#endif #include "esp_crypto_lock.h" #include "hal/aes_hal.h" #include "aes/esp_aes_internal.h" diff --git a/components/mbedtls/port/esp_bignum.c b/components/mbedtls/port/esp_bignum.c index 50969531c8..96601e056c 100644 --- a/components/mbedtls/port/esp_bignum.c +++ b/components/mbedtls/port/esp_bignum.c @@ -20,7 +20,9 @@ #include "esp_log.h" #include "esp_attr.h" #include "esp_intr_alloc.h" +#if CONFIG_PM_ENABLE #include "esp_pm.h" +#endif #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" diff --git a/components/protocomm/CMakeLists.txt b/components/protocomm/CMakeLists.txt index 9f6f683e3b..d98541d8f1 100644 --- a/components/protocomm/CMakeLists.txt +++ b/components/protocomm/CMakeLists.txt @@ -46,5 +46,5 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}" - PRIV_REQUIRES protobuf-c mbedtls console esp_http_server + PRIV_REQUIRES protobuf-c mbedtls console esp_http_server driver REQUIRES bt) diff --git a/components/protocomm/src/transports/protocomm_nimble.c b/components/protocomm/src/transports/protocomm_nimble.c index f0367c4ba5..2af8f9ff9e 100644 --- a/components/protocomm/src/transports/protocomm_nimble.c +++ b/components/protocomm/src/transports/protocomm_nimble.c @@ -7,7 +7,6 @@ #include #include #include -#include "nvs_flash.h" #include #include diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_coex_test/components/case/wifi_connect.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_coex_test/components/case/wifi_connect.c index 997156e762..6ceb5c4265 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_coex_test/components/case/wifi_connect.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_coex_test/components/case/wifi_connect.c @@ -1,7 +1,7 @@ /* * ESP BLE Mesh Example * - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -23,7 +23,6 @@ #include "esp_log.h" #include "esp_netif.h" -#include "driver/gpio.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" diff --git a/examples/bluetooth/esp_hid_device/main/CMakeLists.txt b/examples/bluetooth/esp_hid_device/main/CMakeLists.txt index 7fd7a52f0e..95b2b14c70 100644 --- a/examples/bluetooth/esp_hid_device/main/CMakeLists.txt +++ b/examples/bluetooth/esp_hid_device/main/CMakeLists.txt @@ -4,4 +4,5 @@ set(include_dirs ".") idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" - REQUIRES esp_hid) + REQUIRES esp_hid + PRIV_REQUIRES nvs_flash) diff --git a/examples/bluetooth/esp_hid_host/main/CMakeLists.txt b/examples/bluetooth/esp_hid_host/main/CMakeLists.txt index 178d1bfa74..48060133ec 100644 --- a/examples/bluetooth/esp_hid_host/main/CMakeLists.txt +++ b/examples/bluetooth/esp_hid_host/main/CMakeLists.txt @@ -4,4 +4,5 @@ set(include_dirs ".") idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" - REQUIRES esp_hid) + REQUIRES esp_hid + PRIV_REQUIRES nvs_flash)