From 1d4061d3f2146772a588db39ac52ccbcfcf2ebc3 Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Wed, 8 Dec 2021 16:56:49 +0800 Subject: [PATCH] refactor (nvs_flash)!: removed mbedtls as default dependency mbedtls is only required in NVS if NVS encryption is enabled. Hence the mbedtls dependency is now only added if encryption is enabled, otherwise it is not added. BREAKING CHANGE: Removed mbedtls as default dependency --- components/bt/CMakeLists.txt | 2 +- components/nvs_flash/CMakeLists.txt | 14 +++----------- components/nvs_flash/test/CMakeLists.txt | 4 ++++ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index 1c4ebb48c5..758e4a9436 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -601,7 +601,7 @@ 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 + REQUIRES nvs_flash soc esp_timer esp_pm esp_phy mbedtls LDFRAGMENTS "linker.lf") if(CONFIG_BT_ENABLED) diff --git a/components/nvs_flash/CMakeLists.txt b/components/nvs_flash/CMakeLists.txt index 063ffc0832..640e74d3c5 100644 --- a/components/nvs_flash/CMakeLists.txt +++ b/components/nvs_flash/CMakeLists.txt @@ -24,19 +24,11 @@ if(${target} STREQUAL "linux") message(FATAL_ERROR "NVS currently doesn't support encryption if built for Linux.") endif() target_compile_options(${COMPONENT_LIB} PUBLIC "-DLINUX_TARGET") -else() - # TODO: this is a workaround until IDF-2085 is fixed - idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB) - target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_lib}) + target_compile_options(${COMPONENT_LIB} PUBLIC --coverage) + target_link_libraries(${COMPONENT_LIB} PUBLIC --coverage) endif() if(CONFIG_NVS_ENCRYPTION) target_sources(${COMPONENT_LIB} PRIVATE "src/nvs_encrypted_partition.cpp") - idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB) - target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_lib}) -endif() - -if(${target} STREQUAL "linux") - target_compile_options(${COMPONENT_LIB} PUBLIC --coverage) - target_link_libraries(${COMPONENT_LIB} PUBLIC --coverage) + target_link_libraries(${COMPONENT_LIB} PRIVATE idf::mbedtls) endif() diff --git a/components/nvs_flash/test/CMakeLists.txt b/components/nvs_flash/test/CMakeLists.txt index f69580398b..725e25e3da 100644 --- a/components/nvs_flash/test/CMakeLists.txt +++ b/components/nvs_flash/test/CMakeLists.txt @@ -2,3 +2,7 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." PRIV_REQUIRES cmock test_utils nvs_flash bootloader_support EMBED_TXTFILES encryption_keys.bin partition_encrypted.bin sample.bin) + +if(CONFIG_NVS_ENCRYPTION) + target_link_libraries(${COMPONENT_LIB} PUBLIC idf::mbedtls) +endif()