|
1 |
| -set(COMPONENT_SRCDIRS "src") |
2 |
| -set(COMPONENT_ADD_INCLUDEDIRS "include") |
| 1 | +idf_build_get_property(target IDF_TARGET) |
3 | 2 |
|
4 |
| -set(COMPONENT_PRIV_REQUIRES "spi_flash") |
| 3 | +set(srcs "src/nvs_api.cpp" |
| 4 | + "src/nvs_cxx_api.cpp" |
| 5 | + "src/nvs_item_hash_list.cpp" |
| 6 | + "src/nvs_page.cpp" |
| 7 | + "src/nvs_pagemanager.cpp" |
| 8 | + "src/nvs_storage.cpp" |
| 9 | + "src/nvs_handle_simple.cpp" |
| 10 | + "src/nvs_handle_locked.cpp" |
| 11 | + "src/nvs_partition.cpp" |
| 12 | + "src/nvs_partition_lookup.cpp" |
| 13 | + "src/nvs_partition_manager.cpp" |
| 14 | + "src/nvs_types.cpp") |
5 | 15 |
|
6 |
| -register_component() |
| 16 | +set(public_req spi_flash) |
| 17 | + |
| 18 | +set(include_dirs "include") |
| 19 | + |
| 20 | +idf_component_register(SRCS "${srcs}" |
| 21 | + REQUIRES "${public_req}" |
| 22 | + INCLUDE_DIRS "${include_dirs}") |
| 23 | + |
| 24 | +# If we use the linux target, we need to redirect the crc functions to the linux |
| 25 | +if(${target} STREQUAL "linux") |
| 26 | + if(CONFIG_NVS_ENCRYPTION) |
| 27 | + # mbedtls isn't configured for building with linux or as mock target. It will draw in all kind of dependencies |
| 28 | + message(FATAL_ERROR "NVS currently doesn't support encryption if built for Linux.") |
| 29 | + endif() |
| 30 | + idf_component_get_property(spi_flash_dir spi_flash COMPONENT_DIR) |
| 31 | + target_include_directories(${COMPONENT_LIB} PUBLIC |
| 32 | + "${CMAKE_CURRENT_SOURCE_DIR}/mock/int" |
| 33 | + "${spi_flash_dir}/sim/stubs/freertos/include") |
| 34 | + target_sources(${COMPONENT_LIB} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/mock/int/crc.cpp") |
| 35 | + target_compile_options(${COMPONENT_LIB} PUBLIC "-DLINUX_TARGET") |
| 36 | +else() |
| 37 | + # TODO: this is a workaround until IDF-2085 is fixed |
| 38 | + idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB) |
| 39 | + target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_lib}) |
| 40 | +endif() |
| 41 | + |
| 42 | +if(CONFIG_NVS_ENCRYPTION) |
| 43 | + target_sources(${COMPONENT_LIB} PRIVATE "src/nvs_encrypted_partition.cpp") |
| 44 | + idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB) |
| 45 | + target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_lib}) |
| 46 | +endif() |
| 47 | + |
| 48 | +if(${target} STREQUAL "linux") |
| 49 | + target_compile_options(${COMPONENT_LIB} PUBLIC --coverage) |
| 50 | + target_link_libraries(${COMPONENT_LIB} PUBLIC --coverage) |
| 51 | +endif() |
0 commit comments