代码拉取完成,页面将自动刷新
同步操作将从 DistributedDB/kate 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
cmake_minimum_required(VERSION 3.2)
project(distributed_ut VERSION 1.0.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17 -pthread")
add_compile_options(-Werror=sign-compare)
add_compile_options(-Wno-conversion-null)
add_compile_options(-Wuninitialized)
add_compile_options(-Wformat)
add_compile_options(-Wno-deprecated-declarations)
# Address Sanitizer
option(USE_ASAN "Compile with address sanitiser" OFF)
if (USE_ASAN)
message(STATUS "Compile with address sanitiser ${USE_ASAN}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -O1")
endif()
function(download_repo repo_name repo_url)
execute_process(
COMMAND [ -d ${repo_name} ]
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party
RESULT_VARIABLE REPO_EXISTS
)
message(STATUS "check ${repo_name} exists result: ${REPO_EXISTS}")
if (NOT (${REPO_EXISTS} EQUAL 0))
message(STATUS "Downloading ${repo_name} from ${repo_url}")
execute_process(
COMMAND git clone ${repo_url}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party
)
message(STATUS "Download ${repo_name} finished")
endif()
endfunction(download_repo)
# create third_party directory
execute_process(
COMMAND mkdir -p ${PROJECT_SOURCE_DIR}/third_party
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
# Download dependencies
download_repo("third_party_jsoncpp" "https://gitee.com/openharmony/third_party_jsoncpp.git")
download_repo("third_party_googletest" "https://gitee.com/openharmony/third_party_googletest.git")
download_repo("third_party_openssl" "https://gitee.com/openharmony/third_party_openssl.git")
download_repo("third_party_zlib" "https://gitee.com/openharmony/third_party_zlib.git")
download_repo("third_party_sqlite" "https://gitee.com/openharmony/third_party_sqlite.git")
download_repo("utils_native" "https://gitee.com/openharmony/utils_native.git")
download_repo("kate" "https://gitee.com/lianhuix/kate.git")
function(build_repo repo_name script_path)
execute_process(
COMMAND [ -f ${repo_name}/Makefile ]
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party
RESULT_VARIABLE SCRIPT_EXISTS
)
if (NOT (${SCRIPT_EXISTS} EQUAL 0))
message(STATUS "Copy build script ${script_path}/Makefile to repo ${repo_name}")
execute_process(
COMMAND cp third_party/kate/${script_path}/Makefile third_party/${repo_name} -f
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
message(STATUS "Build ${repo_name}")
execute_process(
COMMAND make -j9
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/${repo_name}
)
message(STATUS "Build finished")
endif()
endfunction(build_repo)
function(cmake_repo repo_name)
execute_process(
COMMAND [ -d ${repo_name}/build ]
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party
RESULT_VARIABLE BUILD_FINISHED
)
if (NOT (${BUILD_FINISHED} EQUAL 0))
message(STATUS "compile repo ${repo_name}")
execute_process(
COMMAND mkdir -p build
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/${repo_name}
)
execute_process(
COMMAND cmake ..
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/${repo_name}/build
)
execute_process(
COMMAND make -j9
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/${repo_name}/build
)
endif()
endfunction(cmake_repo)
function(build_openssl repo_name)
execute_process(
COMMAND [ -f Makefile ]
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/${repo_name}
RESULT_VARIABLE BUILD_FINISHED
)
if (NOT (${BUILD_FINISHED} EQUAL 0))
message(STATUS "compile repo ${repo_name}")
execute_process(
COMMAND chmod +x ./config
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/${repo_name}
)
execute_process(
COMMAND ./config
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/${repo_name}
)
execute_process(
COMMAND make -j9
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/${repo_name}
)
endif()
endfunction(build_openssl)
# build openssl Makefile
build_openssl("third_party_openssl")
# build securec
build_repo("utils_native" "securec")
# build sqlite
build_repo("third_party_sqlite" "sqlite")
# build jsoncpp
cmake_repo("third_party_jsoncpp")
# build zlib
cmake_repo("third_party_zlib")
#build googletest
execute_process(
COMMAND sed -i /Wshadow/d internal_utils.cmake
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/third_party_googletest/googletest/cmake
)
execute_process(
COMMAND sed -i "s%testing::GTEST_FLAG(output)%// testing::GTEST_FLAG(output)%g" googlemock/src/gmock_main.cc
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/third_party_googletest
)
execute_process(
COMMAND sed -i "s%testing::GTEST_FLAG(output)%// testing::GTEST_FLAG(output)%g" googletest/src/gtest_main.cc
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/third_party_googletest
)
cmake_repo("third_party_googletest")
# add_definitions(-Wno-format)
add_definitions(-DSQLITE_ENABLE_SNAPSHOT)
add_definitions(-D_LARGEFILE64_SOURCE)
add_definitions(-D_FILE_OFFSET_BITS=64)
add_definitions(-DSQLITE_HAS_CODEC)
add_definitions(-DSQLITE_ENABLE_JSON1)
add_definitions(-DUSING_HILOG_LOGGER)
# add_definitions(-DUSE_SQLITE_SYMBOLS)
add_definitions(-DUSING_DB_JSON_EXTRACT_AUTOMATICALLY)
add_definitions(-DJSONCPP_USE_BUILDER)
add_definitions(-DOMIT_FLATBUFFER)
add_definitions(-DUSE_PRINT)
add_definitions(-DRELATIONAL_STORE)
# add_definitions(-DSQLITE3_HW_EXPORT_SYMBOLS)
add_definitions(-DTEST_DB)
add_definitions(-DDB_DEBUG_ENV)
add_definitions(-DTESTCASES_USING_GTEST_EXT)
add_definitions(-DSQLITE_DISTRIBUTE_RELATIONAL)
add_definitions(-DSQLITE_ENABLE_DROPTABLE_CALLBACK)
find_package(Threads)
enable_testing()
set(DB_PATH ${PROJECT_SOURCE_DIR}/frameworks/libs/distributeddb)
include_directories(
${DB_PATH}/common/include
${DB_PATH}/common/include/cloud
${DB_PATH}/common/include/relational
${DB_PATH}/common/src
${DB_PATH}/common/src/evloop/include
${DB_PATH}/common/src/evloop/src
${DB_PATH}/communicator/include
${DB_PATH}/communicator/src
${DB_PATH}/include
${DB_PATH}/interfaces/include
${DB_PATH}/interfaces/include/cloud
${DB_PATH}/interfaces/include/relational
${DB_PATH}/interfaces/src
${DB_PATH}/interfaces/src/relational
${DB_PATH}/storage/include
${DB_PATH}/storage/src
${DB_PATH}/storage/src/multiver
${DB_PATH}/storage/src/operation
${DB_PATH}/storage/src/sqlite
${DB_PATH}/storage/src/naturalbase_lite
${DB_PATH}/storage/src/sqlite/relational
${DB_PATH}/storage/src/upgrader
${DB_PATH}/syncer/include
${DB_PATH}/syncer/src
${DB_PATH}/syncer/src/cloud
${DB_PATH}/test/unittest/common/common
${DB_PATH}/test/unittest/common/communicator
${DB_PATH}/test/unittest/common/interfaces
${DB_PATH}/test/unittest/common/storage
${DB_PATH}/test/unittest/common/syncer
${DB_PATH}/test/unittest/common/syncer/cloud
)
include_directories(
${PROJECT_SOURCE_DIR}/third_party/third_party_googletest/googletest/include
${PROJECT_SOURCE_DIR}/third_party/third_party_googletest/googlemock/include
${PROJECT_SOURCE_DIR}/third_party/third_party_jsoncpp/include
${PROJECT_SOURCE_DIR}/third_party/third_party_sqlite/include
${PROJECT_SOURCE_DIR}/third_party/utils_native/base/include
${PROJECT_SOURCE_DIR}/third_party/utils_native/base/src/securec
${PROJECT_SOURCE_DIR}/third_party/third_party_openssl/include
${PROJECT_SOURCE_DIR}/third_party/third_party_zlib
${PROJECT_SOURCE_DIR}/third_party/kate/log/include
)
link_directories(
${PROJECT_SOURCE_DIR}/third_party/third_party_googletest/build/lib
${PROJECT_SOURCE_DIR}/third_party/third_party_jsoncpp/build/lib
${PROJECT_SOURCE_DIR}/third_party/third_party_openssl
${PROJECT_SOURCE_DIR}/third_party/third_party_zlib/build
${PROJECT_SOURCE_DIR}/third_party/third_party_sqlite
${PROJECT_SOURCE_DIR}/third_party/utils_native
)
message("DB_PATH = ${DB_PATH}")
file(GLOB_RECURSE DISTRIBUTEDDB_SRC "${DB_PATH}/*.cpp")
list(REMOVE_ITEM DISTRIBUTEDDB_SRC "${DB_PATH}/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp")
file(GLOB_RECURSE FUZZTEST_SRC "${DB_PATH}/test/fuzztest/*.cpp")
if(FUZZTEST_SRC)
list(REMOVE_ITEM DISTRIBUTEDDB_SRC ${FUZZTEST_SRC})
endif()
foreach (ITR ${DISTRIBUTEDDB_SRC})
if ("${ITR}" MATCHES "(.*)moduletest(.*)")
list (REMOVE_ITEM DISTRIBUTEDDB_SRC ${ITR})
endif ("${ITR}" MATCHES "(.*)moduletest(.*)")
endforeach(ITR)
add_executable(distributed_ut ${DISTRIBUTEDDB_SRC} ${SECUREC_SRC} ${SQLITE_SRC})
target_link_libraries(
distributed_ut
pthread
${CMAKE_THREAD_LIBS_INIT}
securec
jsoncpp
ssl
crypto
sqlite3
z
gtest
gtest_main
gmock
gmock_main
dl
)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。