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
This commit is contained in:
Jakob Hasse 2021-12-08 16:56:49 +08:00
parent c2b8535205
commit 1d4061d3f2
3 changed files with 8 additions and 12 deletions

View File

@ -601,7 +601,7 @@ 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}"
REQUIRES nvs_flash soc esp_timer esp_pm esp_phy REQUIRES nvs_flash soc esp_timer esp_pm esp_phy mbedtls
LDFRAGMENTS "linker.lf") LDFRAGMENTS "linker.lf")
if(CONFIG_BT_ENABLED) if(CONFIG_BT_ENABLED)

View File

@ -24,19 +24,11 @@ if(${target} STREQUAL "linux")
message(FATAL_ERROR "NVS currently doesn't support encryption if built for Linux.") message(FATAL_ERROR "NVS currently doesn't support encryption if built for Linux.")
endif() endif()
target_compile_options(${COMPONENT_LIB} PUBLIC "-DLINUX_TARGET") target_compile_options(${COMPONENT_LIB} PUBLIC "-DLINUX_TARGET")
else() target_compile_options(${COMPONENT_LIB} PUBLIC --coverage)
# TODO: this is a workaround until IDF-2085 is fixed target_link_libraries(${COMPONENT_LIB} PUBLIC --coverage)
idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB)
target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_lib})
endif() endif()
if(CONFIG_NVS_ENCRYPTION) if(CONFIG_NVS_ENCRYPTION)
target_sources(${COMPONENT_LIB} PRIVATE "src/nvs_encrypted_partition.cpp") target_sources(${COMPONENT_LIB} PRIVATE "src/nvs_encrypted_partition.cpp")
idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB) target_link_libraries(${COMPONENT_LIB} PRIVATE idf::mbedtls)
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)
endif() endif()

View File

@ -2,3 +2,7 @@ idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "." PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES cmock test_utils nvs_flash bootloader_support PRIV_REQUIRES cmock test_utils nvs_flash bootloader_support
EMBED_TXTFILES encryption_keys.bin partition_encrypted.bin sample.bin) EMBED_TXTFILES encryption_keys.bin partition_encrypted.bin sample.bin)
if(CONFIG_NVS_ENCRYPTION)
target_link_libraries(${COMPONENT_LIB} PUBLIC idf::mbedtls)
endif()