From d251c451413143c5fa73576c6ca363d20a7d2b87 Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Mon, 8 Jan 2024 16:00:14 +0000 Subject: [PATCH] #1588 use leveldb from deps --- CMakeLists.txt | 12 +++++----- deps/build.sh | 45 ++++++++++++++++++++++++++++++++++++ libbatched-io/CMakeLists.txt | 2 +- libconsensus | 2 +- libdevcore/CMakeLists.txt | 12 ++++++---- 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b034843c3..7ca314bd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,12 +142,12 @@ set( SKALE_HAVE_BOOST_FROM_HUNTER true ) option( BUILD_LEVELDB "Build leveldb from leveldb directory" OFF ) -if( BUILD_LEVELDB ) - add_subdirectory( leveldb ) -else() - hunter_add_package( leveldb ) - find_package( leveldb CONFIG REQUIRED ) -endif() +# if( BUILD_LEVELDB ) +# add_subdirectory( leveldb ) +# else() +# hunter_add_package( leveldb ) +# find_package( leveldb CONFIG REQUIRED ) +# endif() #hunter_add_package( jsoncpp ) #find_package( jsoncpp PATHS "${DEPS_INSTALL_ROOT}/libs/cmake" ) #( jsoncpp CONFIG REQUIRED ) diff --git a/deps/build.sh b/deps/build.sh index 664c42448..a455bc9a2 100755 --- a/deps/build.sh +++ b/deps/build.sh @@ -297,6 +297,7 @@ setup_variable WITH_WANGLE "yes" setup_variable WITH_GTEST "yes" setup_variable WITH_FIZZ "yes" setup_variable WITH_PROXYGEN "yes" +setup_variable WITH_LEVELDB "yes" if [ -z "${PARALLEL_COUNT}" ]; then @@ -610,6 +611,7 @@ echo -e "${COLOR_VAR_NAME}WITH_WANGLE${COLOR_DOTS}............${COLOR_VAR_DESC}L echo -e "${COLOR_VAR_NAME}WITH_GTEST${COLOR_DOTS}.............${COLOR_VAR_DESC}LibGTEST${COLOR_DOTS}...............................${COLOR_VAR_VAL}$WITH_GTEST${COLOR_RESET}" echo -e "${COLOR_VAR_NAME}WITH_FIZZ${COLOR_DOTS}..............${COLOR_VAR_DESC}LibFIZZ${COLOR_DOTS}................................${COLOR_VAR_VAL}$WITH_FIZZ${COLOR_RESET}" echo -e "${COLOR_VAR_NAME}WITH_PROXYGEN${COLOR_DOTS}..........${COLOR_VAR_DESC}LibProxygen${COLOR_DOTS}............................${COLOR_VAR_VAL}$WITH_PROXYGEN${COLOR_RESET}" +echo -e "${COLOR_VAR_NAME}WITH_LEVELDB${COLOR_DOTS}..........${COLOR_VAR_DESC}LibLevelDB${COLOR_DOTS}............................${COLOR_VAR_VAL}$WITH_LEVELDB${COLOR_RESET}" # # @@ -2327,6 +2329,49 @@ then fi fi +if [ "$WITH_LEVELDB" = "yes" ]; +then + echo -e "${COLOR_SEPARATOR}==================== ${COLOR_PROJECT_NAME}libLevelDB${COLOR_SEPARATOR} ==================================${COLOR_RESET}" + if [ ! -f "$INSTALL_ROOT/lib/libleveldb.a" ]; + then + env_restore + cd "$SOURCES_ROOT" + if [ ! -d "leveldb" ]; + then + if [ ! -f "leveldb-from-git.tar.gz" ]; + then + echo -e "${COLOR_INFO}getting it from git${COLOR_DOTS}...${COLOR_RESET}" + eval git clone https://github.com/google/leveldb.git --recursive + cd leveldb + eval git checkout 1.22 + cd .. + echo -e "${COLOR_INFO}archiving it${COLOR_DOTS}...${COLOR_RESET}" + eval tar -czf leveldb-from-git.tar.gz ./leveldb + else + echo -e "${COLOR_INFO}unpacking it${COLOR_DOTS}...${COLOR_RESET}" + eval tar -xzf leveldb-from-git.tar.gz + fi + echo -e "${COLOR_INFO}configuring it${COLOR_DOTS}...${COLOR_RESET}" + cd leveldb + sed -i 's/int g_mmap_limit = kDefaultMmapLimit;\+/int g_mmap_limit = 0;/g' ./util/env_posix.cc + eval mkdir -p build + cd build + eval "$CMAKE" .. "${CMAKE_CROSSCOMPILING_OPTS}" -DCMAKE_INSTALL_PREFIX="$INSTALL_ROOT" -DCMAKE_BUILD_TYPE="$TOP_CMAKE_BUILD_TYPE" \ + -DLEVELDB_BUILD_TESTS=OFF -DLEVELDB_BUILD_BENCHMARKS=OFF + cd .. + else + cd leveldb + fi + echo -e "${COLOR_INFO}building it${COLOR_DOTS}...${COLOR_RESET}" + cd build + eval "$MAKE" "${PARALLEL_MAKE_OPTIONS}" + eval "$MAKE" "${PARALLEL_MAKE_OPTIONS}" install + cd "$SOURCES_ROOT" + else + echo -e "${COLOR_SUCCESS}SKIPPED${COLOR_RESET}" + fi +fi + echo -e "${COLOR_SEPARATOR}===================================================================${COLOR_RESET}" echo -e "${COLOR_YELLOW}SKALED dependencies build actions...${COLOR_RESET}" echo -e "${COLOR_SEPARATOR}==================== ${COLOR_PROJECT_NAME}FINISH${COLOR_SEPARATOR} =======================================${COLOR_RESET}" diff --git a/libbatched-io/CMakeLists.txt b/libbatched-io/CMakeLists.txt index 60e8a27be..0111c9702 100644 --- a/libbatched-io/CMakeLists.txt +++ b/libbatched-io/CMakeLists.txt @@ -9,4 +9,4 @@ target_include_directories( devcore PRIVATE ../libdevcore ) -target_link_libraries( batched-io PRIVATE leveldb::leveldb boost_filesystem devcore) +target_link_libraries( batched-io PRIVATE leveldb boost_filesystem devcore) diff --git a/libconsensus b/libconsensus index ddde155ee..c409caebb 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit ddde155ee8ca1e9dbc8adcccab62d9f85a48f1c0 +Subproject commit c409caebbd423ee0fd303d2329b3ee5ee04ca732 diff --git a/libdevcore/CMakeLists.txt b/libdevcore/CMakeLists.txt index 99d179d1e..851e4188b 100644 --- a/libdevcore/CMakeLists.txt +++ b/libdevcore/CMakeLists.txt @@ -31,8 +31,10 @@ target_link_libraries(devcore PUBLIC skale-buildinfo Boost::filesystem Boost::sy #target_include_directories(devcore SYSTEM PUBLIC ${LEVELDB_INCLUDE_DIRS}) #target_link_libraries(devcore PRIVATE ${LEVELDB_LIBRARIES}) -if( BUILD_LEVELDB ) - target_link_libraries(devcore PRIVATE leveldb skutils) -else() - target_link_libraries(devcore PRIVATE leveldb::leveldb skutils) -endif() +# if( BUILD_LEVELDB ) +# target_link_libraries(devcore PRIVATE leveldb skutils) +# else() +# target_link_libraries(devcore PRIVATE leveldb::leveldb skutils) +# endif() + +target_link_libraries(devcore PRIVATE leveldb skutils) \ No newline at end of file