From bc46f5a3af00a58203808c993ee361ddb2820c9e Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Sun, 29 May 2022 19:35:07 -0700 Subject: [PATCH] Convert storage/ targets into STATIC libraries --- storage/CMakeLists.txt | 24 +------------------ storage/blockdevice/CMakeLists.txt | 9 ++++--- .../COMPONENT_DATAFLASH/CMakeLists.txt | 8 +++++-- .../COMPONENT_FLASHIAP/CMakeLists.txt | 8 +++++-- .../COMPONENT_I2CEE/CMakeLists.txt | 8 +++++-- .../source/I2CEEBlockDevice.cpp | 3 ++- .../COMPONENT_OSPIF/CMakeLists.txt | 8 +++++-- .../COMPONENT_QSPIF/CMakeLists.txt | 8 +++++-- .../blockdevice/COMPONENT_SD/CMakeLists.txt | 8 +++++-- .../blockdevice/COMPONENT_SPIF/CMakeLists.txt | 8 +++++-- .../COMPONENT_SPINAND/CMakeLists.txt | 8 +++++-- storage/filesystem/CMakeLists.txt | 8 +++++-- storage/filesystem/fat/CMakeLists.txt | 8 +++++-- storage/filesystem/littlefs/CMakeLists.txt | 10 ++++---- storage/filesystem/littlefsv2/CMakeLists.txt | 8 ++++--- storage/kvstore/CMakeLists.txt | 2 ++ .../direct_access_devicekey/CMakeLists.txt | 8 ++++--- .../kvstore/filesystemstore/CMakeLists.txt | 8 ++++--- storage/kvstore/kv_config/CMakeLists.txt | 8 ++++--- .../kvstore/kvstore_global_api/CMakeLists.txt | 8 ++++--- storage/kvstore/securestore/CMakeLists.txt | 8 ++++--- storage/kvstore/tdbstore/CMakeLists.txt | 8 ++++--- storage/platform/CMakeLists.txt | 4 ++-- 23 files changed, 114 insertions(+), 74 deletions(-) diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt index e27f47dd11..b7951863bc 100644 --- a/storage/CMakeLists.txt +++ b/storage/CMakeLists.txt @@ -2,29 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # List of all storage libraries available. -add_library(mbed-storage INTERFACE) - -add_library(mbed-storage-blockdevice INTERFACE) -add_library(mbed-storage-dataflash INTERFACE) -add_library(mbed-storage-flashiap INTERFACE) -add_library(mbed-storage-i2cee INTERFACE) -add_library(mbed-storage-ospif INTERFACE) -add_library(mbed-storage-qspif INTERFACE) -add_library(mbed-storage-sd INTERFACE) -add_library(mbed-storage-spif INTERFACE) - -add_library(mbed-storage-filesystem INTERFACE) -add_library(mbed-storage-littlefs-v2 INTERFACE) -add_library(mbed-storage-littlefs INTERFACE) -add_library(mbed-storage-fat INTERFACE) - -add_library(mbed-storage-kvstore INTERFACE) -add_library(mbed-storage-tdbstore INTERFACE) -add_library(mbed-storage-filesystemstore INTERFACE) -add_library(mbed-storage-securestore INTERFACE) -add_library(mbed-storage-kv-config INTERFACE) -add_library(mbed-storage-direct-access-devicekey INTERFACE) -add_library(mbed-storage-kv-global-api INTERFACE) +add_library(mbed-storage STATIC EXCLUDE_FROM_ALL) if(${CMAKE_CROSSCOMPILING}) # The directories below contain optional target libraries diff --git a/storage/blockdevice/CMakeLists.txt b/storage/blockdevice/CMakeLists.txt index cf10ad3cc3..fd1c333737 100644 --- a/storage/blockdevice/CMakeLists.txt +++ b/storage/blockdevice/CMakeLists.txt @@ -10,6 +10,8 @@ if(MBED_OS_ENABLE_TESTS) endif() endif() +add_library(mbed-storage-blockdevice STATIC EXCLUDE_FROM_ALL) + if("DATAFLASH" IN_LIST MBED_TARGET_LABELS) add_subdirectory(COMPONENT_DATAFLASH) endif() @@ -38,9 +40,8 @@ if("SPIF" IN_LIST MBED_TARGET_LABELS) add_subdirectory(COMPONENT_SPIF) endif() - target_include_directories(mbed-storage-blockdevice - INTERFACE + PUBLIC . ./include ./include/blockdevice @@ -48,7 +49,7 @@ target_include_directories(mbed-storage-blockdevice ) target_sources(mbed-storage-blockdevice - INTERFACE + PRIVATE source/BufferedBlockDevice.cpp source/ChainingBlockDevice.cpp source/ExhaustibleBlockDevice.cpp @@ -61,3 +62,5 @@ target_sources(mbed-storage-blockdevice source/SFDP.cpp source/SlicingBlockDevice.cpp ) + +target_link_libraries(mbed-storage-blockdevice PUBLIC mbed-core-flags) \ No newline at end of file diff --git a/storage/blockdevice/COMPONENT_DATAFLASH/CMakeLists.txt b/storage/blockdevice/COMPONENT_DATAFLASH/CMakeLists.txt index fb0eb3e43a..fe5760eaa5 100644 --- a/storage/blockdevice/COMPONENT_DATAFLASH/CMakeLists.txt +++ b/storage/blockdevice/COMPONENT_DATAFLASH/CMakeLists.txt @@ -1,13 +1,17 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-dataflash STATIC EXCLUDE_FROM_ALL) + target_sources(mbed-storage-dataflash - INTERFACE + PRIVATE source/DataFlashBlockDevice.cpp ) target_include_directories(mbed-storage-dataflash - INTERFACE + PUBLIC include include/DataFlash ) + +target_link_libraries(mbed-storage-dataflash PUBLIC mbed-storage-blockdevice) \ No newline at end of file diff --git a/storage/blockdevice/COMPONENT_FLASHIAP/CMakeLists.txt b/storage/blockdevice/COMPONENT_FLASHIAP/CMakeLists.txt index c69d226e74..2d324bb892 100644 --- a/storage/blockdevice/COMPONENT_FLASHIAP/CMakeLists.txt +++ b/storage/blockdevice/COMPONENT_FLASHIAP/CMakeLists.txt @@ -1,13 +1,17 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-flashiap STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-flashiap - INTERFACE + PUBLIC include include/FlashIAP ) target_sources(mbed-storage-flashiap - INTERFACE + PRIVATE source/FlashIAPBlockDevice.cpp ) + +target_link_libraries(mbed-storage-flashiap PUBLIC mbed-storage-blockdevice) \ No newline at end of file diff --git a/storage/blockdevice/COMPONENT_I2CEE/CMakeLists.txt b/storage/blockdevice/COMPONENT_I2CEE/CMakeLists.txt index 27a67b534c..e300e5c060 100644 --- a/storage/blockdevice/COMPONENT_I2CEE/CMakeLists.txt +++ b/storage/blockdevice/COMPONENT_I2CEE/CMakeLists.txt @@ -1,13 +1,17 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-i2cee STATIC EXCLUDE_FROM_ALL) + target_sources(mbed-storage-i2cee - INTERFACE + PRIVATE source/I2CEEBlockDevice.cpp ) target_include_directories(mbed-storage-i2cee - INTERFACE + PUBLIC include include/I2CEE ) + +target_link_libraries(mbed-storage-i2cee PUBLIC mbed-storage-blockdevice) \ No newline at end of file diff --git a/storage/blockdevice/COMPONENT_I2CEE/source/I2CEEBlockDevice.cpp b/storage/blockdevice/COMPONENT_I2CEE/source/I2CEEBlockDevice.cpp index 97174a9063..f2825ff6c3 100644 --- a/storage/blockdevice/COMPONENT_I2CEE/source/I2CEEBlockDevice.cpp +++ b/storage/blockdevice/COMPONENT_I2CEE/source/I2CEEBlockDevice.cpp @@ -17,6 +17,7 @@ #include "I2CEEBlockDevice.h" #include "rtos/ThisThread.h" using namespace mbed; +using namespace std::chrono_literals; #define I2CEE_TIMEOUT 10000 @@ -156,7 +157,7 @@ int I2CEEBlockDevice::_sync() return 0; } - rtos::ThisThread::sleep_for(1); + rtos::ThisThread::sleep_for(1s); } return BD_ERROR_DEVICE_ERROR; diff --git a/storage/blockdevice/COMPONENT_OSPIF/CMakeLists.txt b/storage/blockdevice/COMPONENT_OSPIF/CMakeLists.txt index 0cd380760a..91df7e724b 100644 --- a/storage/blockdevice/COMPONENT_OSPIF/CMakeLists.txt +++ b/storage/blockdevice/COMPONENT_OSPIF/CMakeLists.txt @@ -1,13 +1,17 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-ospif STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-ospif - INTERFACE + PUBLIC include include/OSPIF ) target_sources(mbed-storage-ospif - INTERFACE + PRIVATE source/OSPIFBlockDevice.cpp ) + +target_link_libraries(mbed-storage-ospif PUBLIC mbed-storage-blockdevice) \ No newline at end of file diff --git a/storage/blockdevice/COMPONENT_QSPIF/CMakeLists.txt b/storage/blockdevice/COMPONENT_QSPIF/CMakeLists.txt index 22f0de6541..b4327dacb7 100644 --- a/storage/blockdevice/COMPONENT_QSPIF/CMakeLists.txt +++ b/storage/blockdevice/COMPONENT_QSPIF/CMakeLists.txt @@ -1,17 +1,21 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-qspif STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-qspif - INTERFACE + PUBLIC include include/QSPIF ) target_sources(mbed-storage-qspif - INTERFACE + PRIVATE source/QSPIFBlockDevice.cpp ) +target_link_libraries(mbed-storage-qspif PUBLIC mbed-storage-blockdevice) + if(MBED_OS_ENABLE_TESTS) if (NOT BUILD_GREENTEA_TESTS) add_subdirectory(UNITTESTS) diff --git a/storage/blockdevice/COMPONENT_SD/CMakeLists.txt b/storage/blockdevice/COMPONENT_SD/CMakeLists.txt index 19f4986ffb..ded1af9970 100644 --- a/storage/blockdevice/COMPONENT_SD/CMakeLists.txt +++ b/storage/blockdevice/COMPONENT_SD/CMakeLists.txt @@ -1,13 +1,17 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-sd STATIC EXCLUDE_FROM_ALL) + target_sources(mbed-storage-sd - INTERFACE + PRIVATE source/SDBlockDevice.cpp ) target_include_directories(mbed-storage-sd - INTERFACE + PUBLIC include include/SD ) + +target_link_libraries(mbed-storage-sd PUBLIC mbed-storage-blockdevice) diff --git a/storage/blockdevice/COMPONENT_SPIF/CMakeLists.txt b/storage/blockdevice/COMPONENT_SPIF/CMakeLists.txt index 4623ce8ccc..1daa631e0f 100644 --- a/storage/blockdevice/COMPONENT_SPIF/CMakeLists.txt +++ b/storage/blockdevice/COMPONENT_SPIF/CMakeLists.txt @@ -1,13 +1,17 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-spif STATIC EXCLUDE_FROM_ALL) + target_sources(mbed-storage-spif - INTERFACE + PRIVATE source/SPIFBlockDevice.cpp ) target_include_directories(mbed-storage-spif - INTERFACE + PUBLIC include include/SPIF ) + +target_link_libraries(mbed-storage-spif PUBLIC mbed-storage-blockdevice) \ No newline at end of file diff --git a/storage/blockdevice/COMPONENT_SPINAND/CMakeLists.txt b/storage/blockdevice/COMPONENT_SPINAND/CMakeLists.txt index b743beeaf5..87c929b9c1 100644 --- a/storage/blockdevice/COMPONENT_SPINAND/CMakeLists.txt +++ b/storage/blockdevice/COMPONENT_SPINAND/CMakeLists.txt @@ -1,13 +1,17 @@ # Copyright (c) 2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-spinand STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-spinand - INTERFACE + PUBLIC include include/SPINAND ) target_sources(mbed-storage-spinand - INTERFACE + PRIVATE source/SPINANDBlockDevice.cpp ) + +target_link_libraries(mbed-storage-spinand PUBLIC mbed-storage-blockdevice) \ No newline at end of file diff --git a/storage/filesystem/CMakeLists.txt b/storage/filesystem/CMakeLists.txt index c2b2f4fed4..9f9ea4975f 100644 --- a/storage/filesystem/CMakeLists.txt +++ b/storage/filesystem/CMakeLists.txt @@ -9,24 +9,28 @@ if(MBED_OS_ENABLE_TESTS) endif() endif() +add_library(mbed-storage-filesystem STATIC EXCLUDE_FROM_ALL) + add_subdirectory(fat) add_subdirectory(littlefs) add_subdirectory(littlefsv2) target_include_directories(mbed-storage-filesystem - INTERFACE + PUBLIC . ./include ./include/filesystem ) target_sources(mbed-storage-filesystem - INTERFACE + PRIVATE source/Dir.cpp source/File.cpp source/FileSystem.cpp ) +target_link_libraries(mbed-storage-filesystem PUBLIC mbed-storage-blockdevice) + target_compile_definitions(mbed-storage INTERFACE MBED_CONF_FILESYSTEM_PRESENT=1 diff --git a/storage/filesystem/fat/CMakeLists.txt b/storage/filesystem/fat/CMakeLists.txt index c7d6cc169f..1ce154c25f 100644 --- a/storage/filesystem/fat/CMakeLists.txt +++ b/storage/filesystem/fat/CMakeLists.txt @@ -1,8 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-fat STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-fat - INTERFACE + PUBLIC . ./include ./include/fat @@ -10,9 +12,11 @@ target_include_directories(mbed-storage-fat ) target_sources(mbed-storage-fat - INTERFACE + PRIVATE source/FATFileSystem.cpp ChaN/ff.cpp ChaN/ffunicode.cpp ) + +target_link_libraries(mbed-storage-fat PUBLIC mbed-storage-filesystem) \ No newline at end of file diff --git a/storage/filesystem/littlefs/CMakeLists.txt b/storage/filesystem/littlefs/CMakeLists.txt index fde273d39a..9aa592f9cd 100644 --- a/storage/filesystem/littlefs/CMakeLists.txt +++ b/storage/filesystem/littlefs/CMakeLists.txt @@ -1,8 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-littlefs STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-littlefs - INTERFACE + PUBLIC . ./include ./include/littlefs @@ -10,7 +12,7 @@ target_include_directories(mbed-storage-littlefs ) target_sources(mbed-storage-littlefs - INTERFACE + PRIVATE source/LittleFileSystem.cpp littlefs/lfs.c @@ -18,7 +20,7 @@ target_sources(mbed-storage-littlefs ) target_link_libraries(mbed-storage-littlefs - INTERFACE + PUBLIC mbed-storage-blockdevice mbed-storage-filesystem -) +) \ No newline at end of file diff --git a/storage/filesystem/littlefsv2/CMakeLists.txt b/storage/filesystem/littlefsv2/CMakeLists.txt index 812c005628..452272837b 100644 --- a/storage/filesystem/littlefsv2/CMakeLists.txt +++ b/storage/filesystem/littlefsv2/CMakeLists.txt @@ -1,8 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-littlefs-v2 STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-littlefs-v2 - INTERFACE + PUBLIC . ./include ./include/littlefsv2 @@ -10,7 +12,7 @@ target_include_directories(mbed-storage-littlefs-v2 ) target_sources(mbed-storage-littlefs-v2 - INTERFACE + PRIVATE source/LittleFileSystem2.cpp littlefs/lfs2.c @@ -18,7 +20,7 @@ target_sources(mbed-storage-littlefs-v2 ) target_link_libraries(mbed-storage-littlefs-v2 - INTERFACE + PUBLIC mbed-storage-blockdevice mbed-storage-filesystem ) diff --git a/storage/kvstore/CMakeLists.txt b/storage/kvstore/CMakeLists.txt index dfb078aa9d..790ea5e09f 100644 --- a/storage/kvstore/CMakeLists.txt +++ b/storage/kvstore/CMakeLists.txt @@ -9,6 +9,8 @@ if(MBED_OS_ENABLE_TESTS) endif() endif() +add_library(mbed-storage-kvstore INTERFACE) + add_subdirectory(tdbstore) add_subdirectory(filesystemstore) add_subdirectory(securestore) diff --git a/storage/kvstore/direct_access_devicekey/CMakeLists.txt b/storage/kvstore/direct_access_devicekey/CMakeLists.txt index 3ce9524aa3..ce22b98ce9 100644 --- a/storage/kvstore/direct_access_devicekey/CMakeLists.txt +++ b/storage/kvstore/direct_access_devicekey/CMakeLists.txt @@ -1,20 +1,22 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-direct-access-devicekey STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-direct-access-devicekey - INTERFACE + PUBLIC . include include/direct_access_devicekey ) target_sources(mbed-storage-direct-access-devicekey - INTERFACE + PRIVATE source/DirectAccessDevicekey.cpp ) target_link_libraries(mbed-storage-direct-access-devicekey - INTERFACE + PUBLIC mbed-storage-kvstore mbed-storage-kv-config ) diff --git a/storage/kvstore/filesystemstore/CMakeLists.txt b/storage/kvstore/filesystemstore/CMakeLists.txt index 70453fdaf5..633a446349 100644 --- a/storage/kvstore/filesystemstore/CMakeLists.txt +++ b/storage/kvstore/filesystemstore/CMakeLists.txt @@ -9,20 +9,22 @@ if(MBED_OS_ENABLE_TESTS) endif() endif() +add_library(mbed-storage-filesystemstore STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-filesystemstore - INTERFACE + PUBLIC . include include/filesystemstore ) target_sources(mbed-storage-filesystemstore - INTERFACE + PRIVATE source/FileSystemStore.cpp ) target_link_libraries(mbed-storage-filesystemstore - INTERFACE + PUBLIC mbed-storage-kvstore mbed-storage-filesystem mbed-storage-kv-config diff --git a/storage/kvstore/kv_config/CMakeLists.txt b/storage/kvstore/kv_config/CMakeLists.txt index 131bfea36a..cdc34d2650 100644 --- a/storage/kvstore/kv_config/CMakeLists.txt +++ b/storage/kvstore/kv_config/CMakeLists.txt @@ -1,20 +1,22 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-kv-config STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-kv-config - INTERFACE + PUBLIC . include include/kv_config ) target_sources(mbed-storage-kv-config - INTERFACE + PRIVATE source/kv_config.cpp ) target_link_libraries(mbed-storage-kv-config - INTERFACE + PUBLIC mbed-storage-kvstore mbed-storage-blockdevice mbed-storage-tdbstore diff --git a/storage/kvstore/kvstore_global_api/CMakeLists.txt b/storage/kvstore/kvstore_global_api/CMakeLists.txt index 3519665673..028705204a 100644 --- a/storage/kvstore/kvstore_global_api/CMakeLists.txt +++ b/storage/kvstore/kvstore_global_api/CMakeLists.txt @@ -1,21 +1,23 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-kv-global-api STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-kv-global-api - INTERFACE + PUBLIC . include include/kvstore_global_api ) target_sources(mbed-storage-kv-global-api - INTERFACE + PRIVATE source/KVMap.cpp source/kvstore_global_api.cpp ) target_link_libraries(mbed-storage-kv-global-api - INTERFACE + PUBLIC mbed-storage-kvstore mbed-storage-kv-config mbed-storage-blockdevice diff --git a/storage/kvstore/securestore/CMakeLists.txt b/storage/kvstore/securestore/CMakeLists.txt index b6664e23a7..9d18a8f885 100644 --- a/storage/kvstore/securestore/CMakeLists.txt +++ b/storage/kvstore/securestore/CMakeLists.txt @@ -1,20 +1,22 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_library(mbed-storage-securestore STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-securestore - INTERFACE + PUBLIC . include include/securestore ) target_sources(mbed-storage-securestore - INTERFACE + PRIVATE source/SecureStore.cpp ) target_link_libraries(mbed-storage-securestore - INTERFACE + PUBLIC mbed-storage-kvstore mbed-device_key mbed-mbedtls diff --git a/storage/kvstore/tdbstore/CMakeLists.txt b/storage/kvstore/tdbstore/CMakeLists.txt index f324732f58..048c909794 100644 --- a/storage/kvstore/tdbstore/CMakeLists.txt +++ b/storage/kvstore/tdbstore/CMakeLists.txt @@ -9,20 +9,22 @@ if(MBED_OS_ENABLE_TESTS) endif() endif() +add_library(mbed-storage-tdbstore STATIC EXCLUDE_FROM_ALL) + target_include_directories(mbed-storage-tdbstore - INTERFACE + PUBLIC . include include/tdbstore ) target_sources(mbed-storage-tdbstore - INTERFACE + PRIVATE source/TDBStore.cpp ) target_link_libraries(mbed-storage-tdbstore - INTERFACE + PUBLIC mbed-storage-kvstore mbed-storage-blockdevice ) diff --git a/storage/platform/CMakeLists.txt b/storage/platform/CMakeLists.txt index dbae27817d..bb6355aa75 100644 --- a/storage/platform/CMakeLists.txt +++ b/storage/platform/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 target_sources(mbed-storage - INTERFACE + PRIVATE source/PlatformStorage.cpp ) @@ -34,6 +34,6 @@ if("SPIF" IN_LIST MBED_TARGET_LABELS) endif() target_link_libraries(mbed-storage - INTERFACE + PUBLIC ${mbed-storage-libs} )