Skip to content

Commit

Permalink
Merge pull request #13908 from LDong-Arm/kvstore_libraries
Browse files Browse the repository at this point in the history
Restructure KVStore to one library per store type
  • Loading branch information
adbridge authored Dec 11, 2020
2 parents 86ee300 + 479b704 commit 9f18c44
Show file tree
Hide file tree
Showing 39 changed files with 165 additions and 64 deletions.
3 changes: 3 additions & 0 deletions TESTS/configs/baremetal.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"system-storage",
"SecureStore",
"storage",
"kvstore",
"tdbstore",
"filesystemstore",
"kv-global-api",
"direct-access-devicekey",
"kv-config",
Expand Down
3 changes: 3 additions & 0 deletions UNITTESTS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ set(unittest-includes-base
"${PROJECT_SOURCE_DIR}/../storage/kvstore/include"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/kv_config"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/kv_config/include"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/tdbstore/include"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/filesystemstore/include"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/kvstore_global_api/include"
"${PROJECT_SOURCE_DIR}/../drivers"
"${PROJECT_SOURCE_DIR}/../drivers/include"
"${PROJECT_SOURCE_DIR}/../drivers/include/drivers"
Expand Down
2 changes: 2 additions & 0 deletions drivers/device_key/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ target_sources(mbed-device_key
target_link_libraries(mbed-device_key
INTERFACE
mbed-storage-kvstore
mbed-storage-tdbstore
mbed-storage-kv-global-api
)
4 changes: 2 additions & 2 deletions drivers/device_key/source/DeviceKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "mbedtls/cmac.h"
#include "mbedtls/platform.h"
#include "kvstore/KVStore.h"
#include "kvstore/TDBStore.h"
#include "kvstore/KVMap.h"
#include "tdbstore/TDBStore.h"
#include "kvstore_global_api/KVMap.h"
#include "kv_config/kv_config.h"
#include "mbed_wait_api.h"
#include <stdlib.h>
Expand Down
3 changes: 3 additions & 0 deletions platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ target_link_libraries(mbed-psa
INTERFACE
mbed-mbedtls
mbed-storage-kvstore
mbed-storage-tdbstore
mbed-storage-kv-global-api
mbed-device_key
)
11 changes: 6 additions & 5 deletions storage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ 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_subdirectory(blockdevice)
Expand All @@ -29,8 +35,3 @@ target_include_directories(mbed-storage
INTERFACE
.
)

target_compile_definitions(mbed-storage
INTERFACE
MBED_CONF_FILESYSTEM_PRESENT=1
)
5 changes: 5 additions & 0 deletions storage/filesystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ target_sources(mbed-storage-filesystem
source/File.cpp
source/FileSystem.cpp
)

target_compile_definitions(mbed-storage
INTERFACE
MBED_CONF_FILESYSTEM_PRESENT=1
)
30 changes: 7 additions & 23 deletions storage/kvstore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(direct_access_devicekey)
add_subdirectory(kv_config)
add_subdirectory(tdbstore)
add_subdirectory(filesystemstore)
add_subdirectory(securestore)
add_subdirectory(kv_config)
add_subdirectory(direct_access_devicekey)
add_subdirectory(kvstore_global_api)

target_include_directories(mbed-storage-kvstore
INTERFACE
.
./include
./include/kvstore
)

target_sources(mbed-storage-kvstore
INTERFACE
source/FileSystemStore.cpp
source/KVMap.cpp
source/TDBStore.cpp
source/kvstore_global_api.cpp
)

target_link_libraries(mbed-storage-kvstore
INTERFACE
mbed-device_key
mbed-storage-blockdevice
mbed-storage-filesystem
mbed-storage-fat
mbed-storage-littlefs
mbed-storage-flashiap
mbed-storage-sd
include
include/kvstore
)
14 changes: 10 additions & 4 deletions storage/kvstore/direct_access_devicekey/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

target_include_directories(mbed-storage-kvstore
target_include_directories(mbed-storage-direct-access-devicekey
INTERFACE
.
./include
./include/direct_access_devicekey
include
include/direct_access_devicekey
)

target_sources(mbed-storage-kvstore
target_sources(mbed-storage-direct-access-devicekey
INTERFACE
source/DirectAccessDevicekey.cpp
)

target_link_libraries(mbed-storage-direct-access-devicekey
INTERFACE
mbed-storage-kvstore
mbed-storage-kv-config
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include <string.h>
#include "DeviceKey.h"
#include "kvstore/KVStore.h"
#include "kvstore/KVMap.h"
#include "kvstore_global_api/KVMap.h"
#include "kv_config/kv_config.h"
#include "kvstore/TDBStore.h"
#include "tdbstore/TDBStore.h"
#include "FlashIAP.h"
#include "FlashIAPBlockDevice.h"
#include "direct_access_devicekey/DirectAccessDevicekey.h"
Expand Down
21 changes: 21 additions & 0 deletions storage/kvstore/filesystemstore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

target_include_directories(mbed-storage-filesystemstore
INTERFACE
.
include
include/filesystemstore
)

target_sources(mbed-storage-filesystemstore
INTERFACE
source/FileSystemStore.cpp
)

target_link_libraries(mbed-storage-filesystemstore
INTERFACE
mbed-storage-kvstore
mbed-storage-filesystem
mbed-storage-kv-config
)
3 changes: 3 additions & 0 deletions storage/kvstore/filesystemstore/mbed_lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "filesystemstore"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

#include "kvstore/FileSystemStore.h"
#include "filesystemstore/FileSystemStore.h"
#include "kv_config/kv_config.h"
#include "filesystem/Dir.h"
#include "filesystem/File.h"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "gtest/gtest.h"
#include "blockdevice/HeapBlockDevice.h"
#include "kvstore/FileSystemStore.h"
#include "filesystemstore/FileSystemStore.h"
#include "littlefs/LittleFileSystem.h"
#include "mbed_error.h"
#include <stdlib.h>
Expand All @@ -34,7 +34,7 @@ class FileSystemStoreModuleTest : public testing::Test {
virtual void SetUp()
{
fs = new LittleFileSystem("kvstore", &heap);
if(fs->mount(&heap) != MBED_SUCCESS) {
if (fs->mount(&heap) != MBED_SUCCESS) {
EXPECT_EQ(fs->reformat(&heap), MBED_SUCCESS);
}
store = new FileSystemStore(fs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(unittest-includes ${unittest-includes}

set(unittest-sources
../storage/blockdevice/source/HeapBlockDevice.cpp
../storage/kvstore/source/FileSystemStore.cpp
../storage/kvstore/filesystemstore/source/FileSystemStore.cpp
../storage/filesystem/littlefs/source/LittleFileSystem.cpp
../storage/filesystem/source/Dir.cpp
../storage/filesystem/source/File.cpp
Expand Down
21 changes: 17 additions & 4 deletions storage/kvstore/kv_config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

target_include_directories(mbed-storage-kvstore
target_include_directories(mbed-storage-kv-config
INTERFACE
.
./include
./include/kv_config
include
include/kv_config
)

target_sources(mbed-storage-kvstore
target_sources(mbed-storage-kv-config
INTERFACE
source/kv_config.cpp
)

target_link_libraries(mbed-storage-kv-config
INTERFACE
mbed-storage-kvstore
mbed-storage-blockdevice
mbed-storage-tdbstore
mbed-storage-filesystemstore
mbed-storage-securestore
mbed-storage-littlefs
mbed-storage-fat
mbed-storage-flashiap
mbed-storage-sd
)
6 changes: 3 additions & 3 deletions storage/kvstore/kv_config/source/kv_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

#include "kv_config.h"
#include "kvstore/KVStore.h"
#include "kvstore/KVMap.h"
#include "kvstore_global_api/KVMap.h"
#include "blockdevice/BlockDevice.h"
#include "filesystem/FileSystem.h"
#include "kvstore/FileSystemStore.h"
#include "filesystemstore/FileSystemStore.h"
#include "blockdevice/SlicingBlockDevice.h"
#include "fat/FATFileSystem.h"
#include "littlefs/LittleFileSystem.h"
#include "kvstore/TDBStore.h"
#include "tdbstore/TDBStore.h"
#include "mbed_error.h"
#include "drivers/FlashIAP.h"
#include "blockdevice/FlashSimBlockDevice.h"
Expand Down
23 changes: 23 additions & 0 deletions storage/kvstore/kvstore_global_api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

target_include_directories(mbed-storage-kv-global-api
INTERFACE
.
include
include/kvstore_global_api
)

target_sources(mbed-storage-kv-global-api
INTERFACE
source/KVMap.cpp
source/kvstore_global_api.cpp
)

target_link_libraries(mbed-storage-kv-global-api
INTERFACE
mbed-storage-kvstore
mbed-storage-kv-config
mbed-storage-blockdevice
mbed-storage-filesystem
)
File renamed without changes.
4 changes: 4 additions & 0 deletions storage/kvstore/kvstore_global_api/mbed_lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "kv-global-api",
"requires": ["kvstore"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

#include "kvstore/KVStore.h"
#include "kvstore/KVMap.h"
#include "kvstore_global_api/KVMap.h"
#include "kv_config/kv_config.h"
#include <stdlib.h>
#include "string.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "kvstore_global_api.h"
#include "kvstore_global_api/kvstore_global_api.h"

#include "kv_config/kv_config.h"
#include "kvstore/KVMap.h"
#include "kvstore_global_api/KVMap.h"
#include "kvstore/KVStore.h"
#include "mbed_error.h"

Expand Down
2 changes: 1 addition & 1 deletion storage/kvstore/mbed_lib.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "kv-global-api"
"name": "kvstore"
}
14 changes: 10 additions & 4 deletions storage/kvstore/securestore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

target_include_directories(mbed-storage-kvstore
target_include_directories(mbed-storage-securestore
INTERFACE
.
./include
./include/securestore
include
include/securestore
)

target_sources(mbed-storage-kvstore
target_sources(mbed-storage-securestore
INTERFACE
source/SecureStore.cpp
)

target_link_libraries(mbed-storage-securestore
INTERFACE
mbed-storage-kvstore
mbed-device_key
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

#include "securestore/SecureStore.h"
#include "kvstore/TDBStore.h"
#include "tdbstore/TDBStore.h"
#ifdef MBED_CONF_RTOS_PRESENT
#include "Thread.h"
#endif
Expand Down
20 changes: 20 additions & 0 deletions storage/kvstore/tdbstore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

target_include_directories(mbed-storage-tdbstore
INTERFACE
.
include
include/tdbstore
)

target_sources(mbed-storage-tdbstore
INTERFACE
source/TDBStore.cpp
)

target_link_libraries(mbed-storage-tdbstore
INTERFACE
mbed-storage-kvstore
mbed-storage-blockdevice
)
File renamed without changes.
3 changes: 3 additions & 0 deletions storage/kvstore/tdbstore/mbed_lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "tdbstore"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

// ----------------------------------------------------------- Includes -----------------------------------------------------------

#include "kvstore/TDBStore.h"
#include "tdbstore/TDBStore.h"

#include <algorithm>
#include <string.h>
Expand Down
1 change: 1 addition & 0 deletions storage/kvstore/tdbstore/tests/UNITTESTS/.mbedignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Loading

0 comments on commit 9f18c44

Please sign in to comment.