提交 bbcd898f 编写于 作者: Z zhiru

cmake: add grpc

Former-commit-id: bea01b348d3db6526703a3d31d3d9b3bcd09782c
上级 3fc40ca6
...@@ -129,12 +129,6 @@ if (MILVUS_ENABLE_PROFILING STREQUAL "ON") ...@@ -129,12 +129,6 @@ if (MILVUS_ENABLE_PROFILING STREQUAL "ON")
ADD_DEFINITIONS(-DMILVUS_ENABLE_PROFILING) ADD_DEFINITIONS(-DMILVUS_ENABLE_PROFILING)
endif() endif()
#set(MILVUS_ENABLE_THRIFT "ON")
message("MILVUS_ENABLE_THRIFT = ${MILVUS_ENABLE_THRIFT}")
if (MILVUS_ENABLE_THRIFT STREQUAL "ON")
ADD_DEFINITIONS(-DMILVUS_ENABLE_THRIFT)
endif()
include_directories(${MILVUS_ENGINE_INCLUDE}) include_directories(${MILVUS_ENGINE_INCLUDE})
include_directories(${MILVUS_ENGINE_SRC}) include_directories(${MILVUS_ENGINE_SRC})
......
...@@ -11,6 +11,7 @@ PROFILING="OFF" ...@@ -11,6 +11,7 @@ PROFILING="OFF"
BUILD_FAISS_WITH_MKL="OFF" BUILD_FAISS_WITH_MKL="OFF"
USE_JFROG_CACHE="OFF" USE_JFROG_CACHE="OFF"
KNOWHERE_OPTS="" KNOWHERE_OPTS=""
MILVUS_WITH_THRIFT="OFF"
while getopts "p:d:t:uhlrcgmj" arg while getopts "p:d:t:uhlrcgmj" arg
do do
...@@ -50,6 +51,9 @@ do ...@@ -50,6 +51,9 @@ do
USE_JFROG_CACHE="ON" USE_JFROG_CACHE="ON"
KNOWHERE_OPTS="${KNOWHERE_OPTS} -j" KNOWHERE_OPTS="${KNOWHERE_OPTS} -j"
;; ;;
e)
MILVUS_WITH_THRIFT="ON"
;;
h) # help h) # help
echo " echo "
...@@ -64,6 +68,7 @@ parameter: ...@@ -64,6 +68,7 @@ parameter:
-g: profiling(default: OFF) -g: profiling(default: OFF)
-m: build faiss with MKL(default: OFF) -m: build faiss with MKL(default: OFF)
-j: use jfrog cache build directory -j: use jfrog cache build directory
-e: enable thrift
usage: usage:
./build.sh -t \${BUILD_TYPE} [-u] [-h] [-g] [-r] [-c] [-m] [-j] ./build.sh -t \${BUILD_TYPE} [-u] [-h] [-g] [-r] [-c] [-m] [-j]
...@@ -102,7 +107,7 @@ if [[ ${MAKE_CLEAN} == "ON" ]]; then ...@@ -102,7 +107,7 @@ if [[ ${MAKE_CLEAN} == "ON" ]]; then
-DMILVUS_DB_PATH=${DB_PATH} \ -DMILVUS_DB_PATH=${DB_PATH} \
-DMILVUS_ENABLE_PROFILING=${PROFILING} \ -DMILVUS_ENABLE_PROFILING=${PROFILING} \
-DBUILD_FAISS_WITH_MKL=${BUILD_FAISS_WITH_MKL} \ -DBUILD_FAISS_WITH_MKL=${BUILD_FAISS_WITH_MKL} \
-DMILVUS_ENABLE_THRIFT=${MILVUS_ENABLE_THRIFT} \ -DMILVUS_WITH_THRIFT=${MILVUS_WITH_THRIFT} \
-DKNOWHERE_BUILD_DIR=${KNOWHERE_BUILD_DIR} \ -DKNOWHERE_BUILD_DIR=${KNOWHERE_BUILD_DIR} \
-DUSE_JFROG_CACHE=${USE_JFROG_CACHE} \ -DUSE_JFROG_CACHE=${USE_JFROG_CACHE} \
$@ ../" $@ ../"
......
...@@ -90,7 +90,7 @@ define_option(MILVUS_WITH_SQLITE_ORM "Build with SQLite ORM library" ON) ...@@ -90,7 +90,7 @@ define_option(MILVUS_WITH_SQLITE_ORM "Build with SQLite ORM library" ON)
define_option(MILVUS_WITH_MYSQLPP "Build with MySQL++" ON) define_option(MILVUS_WITH_MYSQLPP "Build with MySQL++" ON)
define_option(MILVUS_WITH_THRIFT "Build with Apache Thrift library" ON) define_option(MILVUS_WITH_THRIFT "Build with Apache Thrift library" OFF)
define_option(MILVUS_WITH_YAMLCPP "Build with yaml-cpp library" ON) define_option(MILVUS_WITH_YAMLCPP "Build with yaml-cpp library" ON)
......
...@@ -39,7 +39,8 @@ set(MILVUS_THIRDPARTY_DEPENDENCIES ...@@ -39,7 +39,8 @@ set(MILVUS_THIRDPARTY_DEPENDENCIES
ZSTD ZSTD
AWS AWS
libunwind libunwind
gperftools) gperftools
GRPC)
message(STATUS "Using ${MILVUS_DEPENDENCY_SOURCE} approach to find dependencies") message(STATUS "Using ${MILVUS_DEPENDENCY_SOURCE} approach to find dependencies")
...@@ -97,6 +98,8 @@ macro(build_dependency DEPENDENCY_NAME) ...@@ -97,6 +98,8 @@ macro(build_dependency DEPENDENCY_NAME)
build_libunwind() build_libunwind()
elseif("${DEPENDENCY_NAME}" STREQUAL "gperftools") elseif("${DEPENDENCY_NAME}" STREQUAL "gperftools")
build_gperftools() build_gperftools()
elseif("${DEPENDENCY_NAME}" STREQUAL "GRPC")
build_grpc()
else() else()
message(FATAL_ERROR "Unknown thirdparty dependency to build: ${DEPENDENCY_NAME}") message(FATAL_ERROR "Unknown thirdparty dependency to build: ${DEPENDENCY_NAME}")
endif () endif ()
...@@ -448,6 +451,13 @@ else() ...@@ -448,6 +451,13 @@ else()
"https://github.com/gperftools/gperftools/releases/download/gperftools-${GPERFTOOLS_VERSION}/gperftools-${GPERFTOOLS_VERSION}.tar.gz") "https://github.com/gperftools/gperftools/releases/download/gperftools-${GPERFTOOLS_VERSION}/gperftools-${GPERFTOOLS_VERSION}.tar.gz")
endif() endif()
if(DEFINED ENV{MILVUS_GRPC_URL})
set(GRPC_SOURCE_URL "$ENV{MILVUS_GRPC_URL}")
else()
set(GRPC_SOURCE_URL
"http://git.zilliz.tech/kun.yu/grpc/-/archive/master/grpc-master.tar.gz")
endif()
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# ARROW # ARROW
...@@ -2338,7 +2348,6 @@ endmacro() ...@@ -2338,7 +2348,6 @@ endmacro()
if(MILVUS_WITH_LIBUNWIND) if(MILVUS_WITH_LIBUNWIND)
resolve_dependency(libunwind) resolve_dependency(libunwind)
# TODO: Don't use global includes but rather target_include_directories
get_target_property(LIBUNWIND_INCLUDE_DIR libunwind INTERFACE_INCLUDE_DIRECTORIES) get_target_property(LIBUNWIND_INCLUDE_DIR libunwind INTERFACE_INCLUDE_DIRECTORIES)
include_directories(SYSTEM ${LIBUNWIND_INCLUDE_DIR}) include_directories(SYSTEM ${LIBUNWIND_INCLUDE_DIR})
endif() endif()
...@@ -2369,8 +2378,6 @@ macro(build_gperftools) ...@@ -2369,8 +2378,6 @@ macro(build_gperftools)
BUILD_BYPRODUCTS BUILD_BYPRODUCTS
${GPERFTOOLS_STATIC_LIB}) ${GPERFTOOLS_STATIC_LIB})
ExternalProject_Add_StepDependencies(gperftools_ep build libunwind_ep)
file(MAKE_DIRECTORY "${GPERFTOOLS_INCLUDE_DIR}") file(MAKE_DIRECTORY "${GPERFTOOLS_INCLUDE_DIR}")
add_library(gperftools STATIC IMPORTED) add_library(gperftools STATIC IMPORTED)
...@@ -2386,8 +2393,85 @@ endmacro() ...@@ -2386,8 +2393,85 @@ endmacro()
if(MILVUS_WITH_GPERFTOOLS) if(MILVUS_WITH_GPERFTOOLS)
resolve_dependency(gperftools) resolve_dependency(gperftools)
# TODO: Don't use global includes but rather target_include_directories
get_target_property(GPERFTOOLS_INCLUDE_DIR gperftools INTERFACE_INCLUDE_DIRECTORIES) get_target_property(GPERFTOOLS_INCLUDE_DIR gperftools INTERFACE_INCLUDE_DIRECTORIES)
include_directories(SYSTEM ${GPERFTOOLS_INCLUDE_DIR}) include_directories(SYSTEM ${GPERFTOOLS_INCLUDE_DIR})
link_directories(SYSTEM ${GPERFTOOLS_PREFIX}/lib) link_directories(SYSTEM ${GPERFTOOLS_PREFIX}/lib)
endif() endif()
# ----------------------------------------------------------------------
# GRPC
macro(build_grpc)
message(STATUS "Building GRPC-${GRPC_VERSION} from source")
set(GRPC_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/grpc_ep-prefix/src/grpc_ep/install")
set(GRPC_INCLUDE_DIR "${GRPC_PREFIX}/include")
set(GRPC_STATIC_LIB "${GRPC_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}grpc${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GRPC++_STATIC_LIB "${GRPC_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}grpc++${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GRPCPP_CHANNELZ_STATIC_LIB "${GRPC_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}grpcpp_channelz${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GRPC_PROTOBUF_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/grpc_ep-prefix/src/grpc_ep/libs/opt/protobuf")
set(GRPC_PROTOBUF_STATIC_LIB "${GRPC_PROTOBUF_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GRPC_PROTOC_STATIC_LIB "${GRPC_PROTOBUF_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}protoc${CMAKE_STATIC_LIBRARY_SUFFIX}")
externalproject_add(grpc_ep
URL
${GRPC_SOURCE_URL}
${EP_LOG_OPTIONS}
CONFIGURE_COMMAND
""
BUILD_IN_SOURCE
1
BUILD_COMMAND
${MAKE} ${MAKE_BUILD_ARGS} prefix=${GRPC_PREFIX}
INSTALL_COMMAND
${MAKE} install prefix=${GRPC_PREFIX}
BUILD_BYPRODUCTS
${GRPC_STATIC_LIB}
${GRPC++_STATIC_LIB}
${GRPCPP_CHANNELZ_STATIC_LIB}
${GRPC_PROTOBUF_STATIC_LIB}
${GRPC_PROTOC_STATIC_LIB})
file(MAKE_DIRECTORY "${GRPC_INCLUDE_DIR}")
add_library(grpc STATIC IMPORTED)
set_target_properties(grpc
PROPERTIES IMPORTED_LOCATION "${GRPC_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}")
add_library(grpc++ STATIC IMPORTED)
set_target_properties(grpc++
PROPERTIES IMPORTED_LOCATION "${GRPC++_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}")
add_library(grpcpp_channelz STATIC IMPORTED)
set_target_properties(grpcpp_channelz
PROPERTIES IMPORTED_LOCATION "${GRPCPP_CHANNELZ_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}")
add_library(grpc_protobuf STATIC IMPORTED)
set_target_properties(grpc_protobuf
PROPERTIES IMPORTED_LOCATION "${GRPC_PROTOBUF_STATIC_LIB}")
add_library(grpc_protoc STATIC IMPORTED)
set_target_properties(grpc_protoc
PROPERTIES IMPORTED_LOCATION "${GRPC_PROTOC_STATIC_LIB}")
add_dependencies(grpc grpc_ep)
add_dependencies(grpc++ grpc_ep)
add_dependencies(grpcpp_channelz grpc_ep)
add_dependencies(grpc_protobuf grpc_ep)
add_dependencies(grpc_protoc grpc_ep)
endmacro()
if(NOT MILVUS_WITH_THRIFT STREQUAL "ON")
resolve_dependency(GRPC)
get_target_property(GRPC_INCLUDE_DIR grpc INTERFACE_INCLUDE_DIRECTORIES)
include_directories(SYSTEM ${GRPC_INCLUDE_DIR})
link_directories(SYSTEM ${GRPC_PREFIX}/lib)
set(GRPC_THIRD_PARTY_DIR ${CMAKE_CURRENT_BINARY_DIR}/grpc_ep-prefix/src/grpc_ep/third_party)
include_directories(SYSTEM ${GRPC_THIRD_PARTY_DIR}/protobuf/src)
link_directories(SYSTEM ${GRPC_PROTOBUF_LIB_DIR})
endif()
...@@ -35,7 +35,7 @@ set(license_generator_files ...@@ -35,7 +35,7 @@ set(license_generator_files
license/LicenseLibrary.cpp license/LicenseLibrary.cpp
) )
set(service_files set(thrift_service_files
thrift/gen-cpp/MilvusService.cpp thrift/gen-cpp/MilvusService.cpp
thrift/gen-cpp/milvus_constants.cpp thrift/gen-cpp/milvus_constants.cpp
thrift/gen-cpp/milvus_types.cpp thrift/gen-cpp/milvus_types.cpp
...@@ -43,6 +43,11 @@ set(service_files ...@@ -43,6 +43,11 @@ set(service_files
metrics/SystemInfo.h metrics/SystemInfo.h
server/thrift_impl/ThreadPoolServer.cpp server/thrift_impl/ThreadPoolServer.cpp
server/thrift_impl/ThreadPoolServer.h server/thrift_impl/ThreadPoolServer.h
)
set(grpc_service_files
metrics/SystemInfo.cpp
metrics/SystemInfo.h
grpc/gen-milvus/milvus.grpc.pb.cc grpc/gen-milvus/milvus.grpc.pb.cc
grpc/gen-milvus/milvus.pb.cc grpc/gen-milvus/milvus.pb.cc
grpc/gen-status/status.grpc.pb.cc grpc/gen-status/status.grpc.pb.cc
...@@ -73,6 +78,18 @@ include_directories(/usr/include/mysql) ...@@ -73,6 +78,18 @@ include_directories(/usr/include/mysql)
include_directories(grpc/gen-status) include_directories(grpc/gen-status)
include_directories(grpc/gen-milvus) include_directories(grpc/gen-milvus)
if (MILVUS_WITH_THRIFT STREQUAL "ON")
set(client_lib
thrift)
else()
set(client_lib
grpcpp_channelz
grpc++
grpc
grpc_protobuf
grpc_protoc)
endif()
set(third_party_libs set(third_party_libs
knowhere knowhere
SPTAGLibStatic SPTAGLibStatic
...@@ -83,10 +100,7 @@ set(third_party_libs ...@@ -83,10 +100,7 @@ set(third_party_libs
lapack lapack
easyloggingpp easyloggingpp
sqlite sqlite
thrift ${client_lib}
grpc
grpc++
grpcpp_channelz
yaml-cpp yaml-cpp
prometheus-cpp-push prometheus-cpp-push
prometheus-cpp-pull prometheus-cpp-pull
...@@ -200,13 +214,13 @@ set(knowhere_libs ...@@ -200,13 +214,13 @@ set(knowhere_libs
tbb tbb
) )
if (MILVUS_ENABLE_THRIFT STREQUAL "ON") if (MILVUS_WITH_THRIFT STREQUAL "ON")
add_executable(milvus_thrift_server add_executable(milvus_thrift_server
${config_files} ${config_files}
${server_files} ${server_files}
${thriftserver_files} ${thriftserver_files}
${utils_files} ${utils_files}
${service_files} ${thrift_service_files}
${metrics_files} ${metrics_files}
) )
else() else()
...@@ -215,20 +229,20 @@ else() ...@@ -215,20 +229,20 @@ else()
${server_files} ${server_files}
${grpcserver_files} ${grpcserver_files}
${utils_files} ${utils_files}
${service_files} ${grpc_service_files}
${metrics_files} ${metrics_files}
) )
endif() endif()
if (ENABLE_LICENSE STREQUAL "ON") if (ENABLE_LICENSE STREQUAL "ON")
if(MILVUS_ENABLE_THRIFT STREQUAL "ON") if(MILVUS_WITH_THRIFT STREQUAL "ON")
target_link_libraries(milvus_thrift_server ${server_libs} license_check ${knowhere_libs} ${third_party_libs}) target_link_libraries(milvus_thrift_server ${server_libs} license_check ${knowhere_libs} ${third_party_libs})
else() else()
target_link_libraries(milvus_grpc_server ${server_libs} license_check ${knowhere_libs} ${third_party_libs}) target_link_libraries(milvus_grpc_server ${server_libs} license_check ${knowhere_libs} ${third_party_libs})
endif() endif()
else () else ()
if(MILVUS_ENABLE_THRIFT STREQUAL "ON") if(MILVUS_WITH_THRIFT STREQUAL "ON")
target_link_libraries(milvus_thrift_server ${server_libs} ${knowhere_libs} ${third_party_libs}) target_link_libraries(milvus_thrift_server ${server_libs} ${knowhere_libs} ${third_party_libs})
else() else()
target_link_libraries(milvus_grpc_server ${server_libs} ${knowhere_libs} ${third_party_libs}) target_link_libraries(milvus_grpc_server ${server_libs} ${knowhere_libs} ${third_party_libs})
...@@ -247,7 +261,7 @@ if (ENABLE_LICENSE STREQUAL "ON") ...@@ -247,7 +261,7 @@ if (ENABLE_LICENSE STREQUAL "ON")
install(TARGETS license_generator DESTINATION bin) install(TARGETS license_generator DESTINATION bin)
endif () endif ()
if (MILVUS_ENABLE_THRIFT STREQUAL "ON") if (MILVUS_WITH_THRIFT STREQUAL "ON")
install(TARGETS milvus_thrift_server DESTINATION bin) install(TARGETS milvus_thrift_server DESTINATION bin)
else() else()
install(TARGETS milvus_grpc_server DESTINATION bin) install(TARGETS milvus_grpc_server DESTINATION bin)
......
文件模式从 100755 更改为 100644
此差异已折叠。
...@@ -11,20 +11,29 @@ ...@@ -11,20 +11,29 @@
#include <grpcpp/impl/codegen/async_stream.h> #include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h> #include <grpcpp/impl/codegen/async_unary_call.h>
#include <grpcpp/impl/codegen/client_callback.h> #include <grpcpp/impl/codegen/client_callback.h>
#include <grpcpp/impl/codegen/client_context.h>
#include <grpcpp/impl/codegen/completion_queue.h>
#include <grpcpp/impl/codegen/method_handler_impl.h> #include <grpcpp/impl/codegen/method_handler_impl.h>
#include <grpcpp/impl/codegen/proto_utils.h> #include <grpcpp/impl/codegen/proto_utils.h>
#include <grpcpp/impl/codegen/rpc_method.h> #include <grpcpp/impl/codegen/rpc_method.h>
#include <grpcpp/impl/codegen/server_callback.h> #include <grpcpp/impl/codegen/server_callback.h>
#include <grpcpp/impl/codegen/server_context.h>
#include <grpcpp/impl/codegen/service_type.h> #include <grpcpp/impl/codegen/service_type.h>
#include <grpcpp/impl/codegen/status.h> #include <grpcpp/impl/codegen/status.h>
#include <grpcpp/impl/codegen/stub_options.h> #include <grpcpp/impl/codegen/stub_options.h>
#include <grpcpp/impl/codegen/sync_stream.h> #include <grpcpp/impl/codegen/sync_stream.h>
namespace grpc { namespace grpc_impl {
class CompletionQueue; class CompletionQueue;
class Channel;
class ServerCompletionQueue; class ServerCompletionQueue;
class ServerContext; class ServerContext;
} // namespace grpc_impl
namespace grpc {
namespace experimental {
template <typename RequestT, typename ResponseT>
class MessageAllocator;
} // namespace experimental
} // namespace grpc } // namespace grpc
namespace milvus { namespace milvus {
......
此差异已折叠。
...@@ -12,7 +12,7 @@ include_directories(/usr/include) ...@@ -12,7 +12,7 @@ include_directories(/usr/include)
include_directories(include) include_directories(include)
include_directories(/usr/local/include) include_directories(/usr/local/include)
if (MILVUS_ENABLE_THRIFT STREQUAL "ON") if (MILVUS_WITH_THRIFT STREQUAL "ON")
aux_source_directory(thrift thrift_client_files) aux_source_directory(thrift thrift_client_files)
include_directories(thrift) include_directories(thrift)
include_directories(${CMAKE_SOURCE_DIR}/src/thrift/gen-cpp) include_directories(${CMAKE_SOURCE_DIR}/src/thrift/gen-cpp)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Proprietary and confidential. # Proprietary and confidential.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
if (MILVUS_ENABLE_THRIFT STREQUAL "ON") if (MILVUS_WITH_THRIFT STREQUAL "ON")
add_subdirectory(thriftsimple) add_subdirectory(thriftsimple)
else() else()
add_subdirectory(grpcsimple) add_subdirectory(grpcsimple)
......
...@@ -22,5 +22,6 @@ ZSTD_VERSION=v1.4.0 ...@@ -22,5 +22,6 @@ ZSTD_VERSION=v1.4.0
AWS_VERSION=1.7.125 AWS_VERSION=1.7.125
LIBUNWIND_VERSION=1.3.1 LIBUNWIND_VERSION=1.3.1
GPERFTOOLS_VERSION=2.7 GPERFTOOLS_VERSION=2.7
GRPC_VERSION=master
# vim: set filetype=sh: # vim: set filetype=sh:
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册