Skip to content

Commit f9e1426

Browse files
amabluea-maurice
authored andcommitted
Implementation of the LevelDb Storage Engine, which will allow the Database to store data locally on disk between runs.
This is just the implementation and tests, hooking it into the library will be in a separate CL. PiperOrigin-RevId: 312746071
1 parent 584cf5d commit f9e1426

File tree

6 files changed

+962
-0
lines changed

6 files changed

+962
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ if(FIREBASE_CPP_BUILD_TESTS AND NOT FIRESTORE_USE_EXTERNAL_CMAKE_BUILD)
189189
add_external_library(googletest)
190190
endif()
191191

192+
if((FIREBASE_INCLUDE_DATABASE AND DESKTOP) AND NOT FIREBASE_INCLUDE_FIRESTORE)
193+
# LevelDB is needed for Desktop and Firestore, but if firestore is being built
194+
# LevelDB will already be included.
195+
add_external_library(leveldb)
196+
endif()
197+
192198
# Some of the external libraries are not used for mobile.
193199
if(DESKTOP)
194200
# Use the static versions of the OpenSSL libraries.

cmake/external/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ include(firestore)
3030
if (${FIREBASE_EXTERNAL_PLATFORM} STREQUAL "DESKTOP")
3131
include(curl)
3232
include(libuv)
33+
include(leveldb)
3334
include(nanopb)
3435
include(uWebSockets)
3536
include(zlib)

cmake/external/leveldb.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2017 Google
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
include(ExternalProject)
16+
17+
if(TARGET leveldb)
18+
return()
19+
endif()
20+
21+
set(version 1.22)
22+
23+
ExternalProject_Add(
24+
leveldb
25+
26+
DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR}
27+
DOWNLOAD_NAME leveldb-${version}.tar.gz
28+
URL https://github.com/google/leveldb/archive/${version}.tar.gz
29+
URL_HASH SHA256=55423cac9e3306f4a9502c738a001e4a339d1a38ffbee7572d4a07d5d63949b2
30+
31+
PREFIX ${PROJECT_BINARY_DIR}
32+
33+
CONFIGURE_COMMAND ""
34+
BUILD_COMMAND ""
35+
INSTALL_COMMAND ""
36+
TEST_COMMAND ""
37+
)

database/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ set(desktop_SRCS
114114
src/desktop/mutable_data_desktop.cc
115115
src/desktop/persistence/flatbuffer_conversions.cc
116116
src/desktop/persistence/in_memory_persistence_storage_engine.cc
117+
src/desktop/persistence/level_db_persistence_storage_engine.cc
117118
src/desktop/persistence/noop_persistence_manager.cc
118119
src/desktop/persistence/persistence_manager.cc
119120
src/desktop/persistence/prune_forest.cc
@@ -157,6 +158,7 @@ else()
157158
desktop_flatbuffers
158159
firebase_rest_lib
159160
${OPENSSL_CRYPTO_LIBRARY}
161+
leveldb
160162
libuWS)
161163

162164
set(additional_DEFINES

0 commit comments

Comments
 (0)