Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple the client and server source code. #54

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Cpplint
run: |
ln -snf $PWD/.linters/cpp/hooks/pre-commit.sh $PWD/.linters/cpp/pre-commit.sh
.linters/cpp/pre-commit.sh $(git --no-pager diff --diff-filter=d --name-only HEAD^ HEAD)
.linters/cpp/pre-commit.sh

build:
name: build
Expand Down
2 changes: 1 addition & 1 deletion .linters/cpp/hooks/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ $# -eq 0 ];then
echo "You have unstaged changes, please stage or stash them first."
exit 1
fi
CHECK_FILES=$(git diff --name-only --diff-filter=ACMRTUXB HEAD | egrep '.*\.cpp$|.*\.h$|.*\.inl$' | grep -v 'com_vesoft_client_NativeClient.h' | grep -v 'com_vesoft_nebula_NebulaCodec.h')
CHECK_FILES=$(git diff --name-only --diff-filter=ACMRTUXB HEAD | egrep '.*\.cpp$|.*\.h$|.*\.inl$' | grep -v 'com_vesoft_client_NativeClient.h' | grep -v 'com_vesoft_nebula_NebulaCodec.h' | grep -v 'interface')
else
CHECK_FILES=$(find $@ -not \( -path src/CMakeFiles -prune \) \
-not \( -path src/interface/gen-cpp2 -prune \) \
Expand Down
85 changes: 10 additions & 75 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,7 @@ option(DISABLE_CLONE_COMMON "Automatically disable clone common module" OFF)
add_definitions(-DNEBULA_HOME=${CMAKE_SOURCE_DIR})

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

# Submodules
if("${NEBULA_COMMON_REPO_URL}" STREQUAL "")
SET(NEBULA_COMMON_REPO_URL "https://github.com/vesoft-inc/nebula-common.git")
endif()

if("${NEBULA_COMMON_REPO_TAG}" STREQUAL "")
SET(NEBULA_COMMON_REPO_TAG "master")
endif()

include(FetchModule)
if(NOT NEBULA_COMMON_SOURCE_DIR)
if (NOT ${DISABLE_CLONE_COMMON})
nebula_fetch_module(
NAME
common
URL
${NEBULA_COMMON_REPO_URL}
TAG
${NEBULA_COMMON_REPO_TAG}
UPDATE
${ENABLE_MODULE_UPDATE}
)
endif()
set(nebula_common_source_dir ${CMAKE_SOURCE_DIR}/modules/common)
set(nebula_common_build_dir ${CMAKE_BINARY_DIR}/modules/common)
else()
set(nebula_common_source_dir ${NEBULA_COMMON_SOURCE_DIR})
if(NOT NEBULA_COMMON_BUILD_DIR)
set(nebula_common_build_dir ${CMAKE_BINARY_DIR}/modules/common)
else()
set(nebula_common_build_dir ${NEBULA_COMMON_BUILD_DIR})
endif()
endif()

list(APPEND CMAKE_MODULE_PATH ${nebula_common_source_dir}/cmake)
list(APPEND CMAKE_MODULE_PATH ${nebula_common_source_dir}/cmake/nebula)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/nebula)

include(PlatformCheck)
include(NebulaCMakeMacros)
Expand All @@ -82,19 +46,9 @@ include(SanitizerConfig)
include(GitHooksConfig)
include(GitInfoConfig)
include(NebulaCustomTargets)
include(ConfigNebulaCommon)

set(ENABLE_PIC ON FORCE)
set(ENABLE_JEMALLOC OFF FORCE)
config_nebula_common(
SOURCE_DIR ${nebula_common_source_dir}
BUILD_DIR ${nebula_common_build_dir}
)

add_custom_target(
clean-modules
DEPENDS clean-common
)

include(GNUInstallDirs)

Expand All @@ -111,10 +65,6 @@ macro(nebula_add_library name type)
APPEND
FILE ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
)
add_dependencies(
${name}
common_project
)
endmacro()

nebula_add_shared_linker_flag(-static-libstdc++)
Expand All @@ -132,31 +82,16 @@ install(
PATTERN ".gitkeep" EXCLUDE
)

# resuse the datatypes in common
install(DIRECTORY ${nebula_common_source_dir}/src/common/datatypes
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/common
FILES_MATCHING PATTERN "*.h")

# reuse the response of graph in common
install(DIRECTORY ${nebula_common_source_dir}/src/common/graph
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/common
FILES_MATCHING PATTERN "*.h")

# reuse the time utils in common
install(DIRECTORY ${nebula_common_source_dir}/src/common/time
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/common
FILES_MATCHING PATTERN "TimeConversion.h")

# reuse the thrift types in common
install(
FILES
${nebula_common_source_dir}/src/common/thrift/ThriftTypes.h
PERMISSIONS
OWNER_WRITE OWNER_READ
GROUP_READ
WORLD_READ
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/common/thrift
DIRECTORY include/common
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PATTERN ".gitkeep" EXCLUDE
)

add_custom_target(
format
COMMAND "find" "include" "src/client" "src/datatypes" "src/time" "src/graph" "-type" "f" "\\(" "-iname" "\\*.h" "-o" "-iname" "\\*.cpp" "\\)" "|" "xargs" "clang-format" "-i"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

include(CPackage)
Expand Down
170 changes: 170 additions & 0 deletions cmake/CPackage.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Copyright (c) 2020 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License,
# attached with Common Clause Condition 1.0, found in the LICENSES directory.
#


# Used to package into deb or RPM files
macro(package to_one name home_page scripts_dir)
set(CPACK_PACKAGE_DESCRIPTION ${name})
set(CPACK_PACKAGE_CONTACT ${name})
set(CPACK_PACKAGE_VERSION ${NEBULA_BUILD_VERSION})
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0 + Common Clause 1.0")
set(CPACK_PACKAGE_NAME ${name})
# set(CPACK_SET_DESTDIR TRUE)
set(CPACK_PACKAGE_RELOCATABLE ON)
set(CPACK_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
if (EXISTS "/etc/redhat-release")
if(ENABLE_PACKAGE_TAR)
set(CPACK_GENERATOR "TGZ")
else()
set(CPACK_GENERATOR "RPM")
endif()
file (STRINGS "/etc/redhat-release" SYSTEM_NAME)
if (${SYSTEM_NAME} MATCHES "CentOS")
set(HOST_SYSTEM_NAME "el")
execute_process(
COMMAND echo ${SYSTEM_NAME}
COMMAND tr -dc "0-9."
COMMAND cut -d "." -f1
OUTPUT_VARIABLE HOST_SYSTEM_VER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(CONCAT HOST_SYSTEM_VER ${HOST_SYSTEM_NAME} ${HOST_SYSTEM_VER})
elseif (${SYSTEM_NAME} MATCHES "Fedora")
set(HOST_SYSTEM_NAME "fc")
execute_process(
COMMAND echo ${SYSTEM_NAME}
COMMAND cut -d " " -f3
OUTPUT_VARIABLE HOST_SYSTEM_VER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(CONCAT HOST_SYSTEM_VER ${HOST_SYSTEM_NAME} ${HOST_SYSTEM_VER})
else()
set(HOST_SYSTEM_VER "Unknown")
endif()
elseif (EXISTS "/etc/lsb-release")
if(ENABLE_PACKAGE_TAR)
set(CPACK_GENERATOR "TGZ")
else()
set(CPACK_GENERATOR "DEB")
endif()
file (STRINGS "/etc/lsb-release" SYSTEM_NAME)
execute_process(
COMMAND echo "${SYSTEM_NAME}"
COMMAND cut -d ";" -f 1
COMMAND cut -d "=" -f 2
OUTPUT_VARIABLE HOST_SYSTEM_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND echo "${SYSTEM_NAME}"
COMMAND cut -d ";" -f 2
COMMAND cut -d "=" -f 2
OUTPUT_VARIABLE HOST_SYSTEM_VER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REPLACE "." "" HOST_SYSTEM_VER ${HOST_SYSTEM_VER})
if (${HOST_SYSTEM_NAME} MATCHES "Ubuntu")
string(CONCAT HOST_SYSTEM_VER "ubuntu" ${HOST_SYSTEM_VER})
# the ubuntu need to modify the architecture name
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "x86_64")
set(CMAKE_HOST_SYSTEM_PROCESSOR "amd64")
endif()
# Adapt the Kylin system
elseif (${HOST_SYSTEM_NAME} MATCHES "Kylin" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "aarch64")
string(CONCAT HOST_SYSTEM_VER ${HOST_SYSTEM_NAME} ${HOST_SYSTEM_VER})
set(CMAKE_HOST_SYSTEM_PROCESSOR "arm64")
endif()
elseif (EXISTS "/etc/issue")
file (STRINGS "/etc/issue" SYSTEM_NAME)
execute_process(
COMMAND echo "${SYSTEM_NAME}"
COMMAND sed -n "1p"
COMMAND cut -d " " -f 1
OUTPUT_VARIABLE HOST_SYSTEM_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND echo "${SYSTEM_NAME}"
COMMAND sed -n "1p"
COMMAND cut -d " " -f 3
OUTPUT_VARIABLE HOST_SYSTEM_VER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (${HOST_SYSTEM_NAME} MATCHES "Debian")
execute_process(
COMMAND echo "${SYSTEM_NAME}"
COMMAND sed -n "1p"
COMMAND cut -d " " -f 3
OUTPUT_VARIABLE HOST_SYSTEM_VER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(ENABLE_PACKAGE_TAR)
set(CPACK_GENERATOR "TGZ")
else()
set(CPACK_GENERATOR "DEB")
endif()
# Adapt the NeoKylin system
elseif (${HOST_SYSTEM_NAME} MATCHES "NeoKylin" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "mips64")
execute_process(
COMMAND echo "${SYSTEM_NAME}"
COMMAND sed -n "1p"
COMMAND cut -d " " -f 4
OUTPUT_VARIABLE HOST_SYSTEM_VER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CMAKE_HOST_SYSTEM_PROCESSOR "mips64el")
if(ENABLE_PACKAGE_TAR)
set(CPACK_GENERATOR "TGZ")
else()
set(CPACK_GENERATOR "RPM")
endif()
endif()
string(CONCAT HOST_SYSTEM_VER ${HOST_SYSTEM_NAME} ${HOST_SYSTEM_VER})
set(CMAKE_HOST_SYSTEM_PROCESSOR "mips64el")
else()
set(HOST_SYSTEM_VER "Unknown")
endif()

message(STATUS "HOST_SYSTEM_NAME is ${HOST_SYSTEM_NAME}")
message(STATUS "HOST_SYSTEM_VER is ${HOST_SYSTEM_VER}")
message(STATUS "CPACK_GENERATOR is ${CPACK_GENERATOR}")
message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR is ${CMAKE_HOST_SYSTEM_PROCESSOR}")

set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${HOST_SYSTEM_VER}.${CMAKE_HOST_SYSTEM_PROCESSOR})
if (${to_one})
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
else ()
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
endif()

set(CPACK_DEB_COMPONENT_INSTALL YES)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_HOST_SYSTEM_PROCESSOR})
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${home_page})
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${scripts_dir}/postinst)

set(CPACK_RPM_SPEC_MORE_DEFINE "%define debug_package %{nil}
%define __os_install_post %{nil}")
set(CPACK_RPM_COMPONENT_INSTALL YES)
set(CPACK_RPM_PACKAGE_ARCHITECTURE ${CMAKE_HOST_SYSTEM_PROCESSOR})
set(CPACK_RPM_PACKAGE_URL ${home_page})
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${scripts_dir}/rpm_postinst)
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/local)
set(CPACK_RPM_PACKAGE_RELOCATABLE ON)

include(CPack)

cpack_add_component(common GROUP common)
cpack_add_component(graph GROUP graph DEPENDS common)
cpack_add_component(storage GROUP storage DEPENDS common)
cpack_add_component(meta GROUP meta DEPENDS common)
cpack_add_component(tool GROUP tool)
cpack_add_component_group(common)
cpack_add_component_group(graph)
cpack_add_component_group(storage)
cpack_add_component_group(meta)
cpack_add_component_group(tool)
endmacro()
13 changes: 13 additions & 0 deletions cmake/ClangTidy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if (ENABLE_CLANG_TIDY)
if (${CMAKE_VERSION} VERSION_LESS "3.6.0")
message(FATAL_ERROR "clang-tidy requires CMake version at least 3.6.")
endif()

find_program (CLANG_TIDY_PATH NAMES "clang-tidy")
if (CLANG_TIDY_PATH)
message(STATUS "Using clang-tidy: ${CLANG_TIDY_PATH}.")
set (CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PATH} --config=)
else ()
message(STATUS "clang-tidy is not found.")
endif ()
endif ()
Loading