diff --git a/.gitmodules b/.gitmodules index 345e82c9bd0ef14421206788d0d6079720d642d7..3ea3f4a0903a0827c99103d6edb8ce18e96c122e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,10 +34,6 @@ path = third_party/xxhash url = https://github.com/Cyan4973/xxHash.git ignore = dirty -[submodule "third_party/leveldb"] - path = third_party/leveldb - url = https://github.com/google/leveldb - ignore = dirty [submodule "third_party/pybind"] path = third_party/pybind url = https://github.com/pybind/pybind11.git diff --git a/cmake/external/leveldb.cmake b/cmake/external/leveldb.cmake index 4eb630ad0ce8193fc09d4c349d4142918bf220a2..a35b6f429fa30f96f1eed96a11e625e423203a69 100644 --- a/cmake/external/leveldb.cmake +++ b/cmake/external/leveldb.cmake @@ -14,6 +14,8 @@ include(ExternalProject) +set(LEVELDB_TAG v1.18) +set(LEVELDB_SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/leveldb) set(LEVELDB_PREFIX_DIR ${THIRD_PARTY_PATH}/leveldb) set(LEVELDB_INSTALL_DIR ${THIRD_PARTY_PATH}/install/leveldb) set(LEVELDB_INCLUDE_DIR @@ -27,21 +29,43 @@ set(LEVELDN_CXXFLAGS "-fPIC") if(WITH_HETERPS AND WITH_PSLIB) set(LEVELDN_CXXFLAGS "${LEVELDN_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") endif() + +file(GLOB LEVELDB_SOURCE_FILE_LIST ${LEVELDB_SOURCE_DIR}) +list(LENGTH LEVELDB_SOURCE_FILE_LIST RES_LEN) +if(RES_LEN EQUAL 0) + execute_process( + COMMAND ${GIT_EXECUTABLE} clone -b ${LEVELDB_TAG} + https://github.com/google/leveldb.git ${LEVELDB_SOURCE_DIR}) +else() + # check git tag + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --abbrev=6 --always --tags + OUTPUT_VARIABLE VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET + WORKING_DIRECTORY ${LEVELDB_SOURCE_DIR}) + if(NOT ${VERSION} STREQUAL ${LEVELDB_TAG}) + file(REMOVE_RECURSE ${LEVELDB_PREFIX_DIR}) + file(REMOVE_RECURSE ${LEVELDB_INSTALL_DIR}) + message( + WARNING "leveldb version is not ${VERSION}, checkout to ${LEVELDB_TAG}") + execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${LEVELDB_TAG} + WORKING_DIRECTORY ${LEVELDB_SOURCE_DIR}) + endif() +endif() + ExternalProject_Add( extern_leveldb ${EXTERNAL_PROJECT_LOG_ARGS} PREFIX ${LEVELDB_PREFIX_DIR} - GIT_REPOSITORY "https://github.com/google/leveldb" - GIT_TAG v1.18 + SOURCE_DIR ${LEVELDB_SOURCE_DIR} UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND export "CXXFLAGS=${LEVELDN_CXXFLAGS}" && make -j ${NUM_OF_PROCESSOR} libleveldb.a INSTALL_COMMAND mkdir -p ${LEVELDB_INSTALL_DIR}/lib/ && cp - ${LEVELDB_PREFIX_DIR}/src/extern_leveldb/libleveldb.a ${LEVELDB_LIBRARIES} - && cp -r ${LEVELDB_PREFIX_DIR}/src/extern_leveldb/include - ${LEVELDB_INSTALL_DIR}/ + ${LEVELDB_SOURCE_DIR}/libleveldb.a ${LEVELDB_LIBRARIES} && cp -r + ${LEVELDB_SOURCE_DIR}/include ${LEVELDB_INSTALL_DIR}/ BUILD_IN_SOURCE 1 BUILD_BYPRODUCTS ${LEVELDB_LIBRARIES}) add_dependencies(extern_leveldb snappy) diff --git a/third_party/leveldb b/third_party/leveldb deleted file mode 160000 index 803d69203a62faf50f1b77897310a3a1fcae712b..0000000000000000000000000000000000000000 --- a/third_party/leveldb +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 803d69203a62faf50f1b77897310a3a1fcae712b