Skip to content

Commit

Permalink
Feature: Support using trpc protocol at remote side (#124)
Browse files Browse the repository at this point in the history
- import remote side trpc.proto at "trpc/trpc.proto" file.
- use remote side trpc_options.proto instead local one.
- intergate remote trpc protocol repo with bazel and cmake compiling progress.
  • Loading branch information
weimch authored Mar 21, 2024
1 parent 53be380 commit 00af5f2
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 559 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ endif()
set(TRPC_INSTALL_PATH_PREFIX ${TRPC_CMAKE_INSTALL_DEFAULT_PREFIX}/trpc-${TRPC_VERSION}/)
set(CMAKE_INSTALL_PREFIX ${TRPC_INSTALL_PATH_PREFIX})

#---------------------------------------------------------------------------------------
# tRPC Protocol
#---------------------------------------------------------------------------------------
include(trpc_protocol)

# Print tRPC-Cpp version
message(STATUS "Build tRPC-Cpp: v${TRPC_VERSION}")

Expand Down Expand Up @@ -203,6 +208,7 @@ add_subdirectory(${TRPC_ROOT_PATH}/trpc/tools/flatbuffers_tool/)
#---------------------------------------------------------------------------------------
set(GEN_PB_PROTO_FILES ${TRPC_ROOT_PATH}/trpc/codec/trpc/trpc.proto
${TRPC_ROOT_PATH}/trpc/proto/trpc.proto
${TRPC_ROOT_PATH}/trpc/trpc.proto
${TRPC_ROOT_PATH}/trpc/proto/trpc_options.proto
${TRPC_ROOT_PATH}/trpc/tools/comm/trpc_cpp_options.proto)

Expand Down
35 changes: 35 additions & 0 deletions cmake/trpc_protocol.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
#
# Tencent is pleased to support the open source community by making tRPC available.
#
# Copyright (C) 2024 THL A29 Limited, a Tencent company.
# All rights reserved.
#
# If you have downloaded a copy of the tRPC source code from Tencent,
# please note that tRPC source code is licensed under the Apache 2.0 License,
# A copy of the Apache 2.0 License is included in this file.
#
#

# 下载外部依赖源文件需要使用到cmake的FetchContent命令
include(FetchContent)

# 定义外部库的版本
set(TRPC_PROTOCOL_GIT_VER v1.0.0)
set(TRPC_PROTOCOL_GIT_URL https://github.com/trpc-group/trpc.git)

FetchContent_Declare(
com_github_trpc_protocol
GIT_REPOSITORY ${TRPC_PROTOCOL_GIT_URL}
GIT_TAG ${TRPC_PROTOCOL_GIT_VER}
SOURCE_DIR ${TRPC_ROOT_PATH}/cmake_third_party/trpc_protocol #指定库源文件下载的目录
)
FetchContent_GetProperties(com_github_trpc_protocol)

if(NOT com_github_trpc_protocol_POPULATED)
FetchContent_Populate(com_github_trpc_protocol)
execute_process(COMMAND cp -fp ${TRPC_ROOT_PATH}/cmake_third_party/trpc_protocol/trpc/trpc.proto .
WORKING_DIRECTORY ${TRPC_ROOT_PATH}/trpc)
execute_process(COMMAND cp -fp ${TRPC_ROOT_PATH}/cmake_third_party/trpc_protocol/trpc/proto/trpc_options.proto .
WORKING_DIRECTORY ${TRPC_ROOT_PATH}/trpc/proto)
endif()
2 changes: 1 addition & 1 deletion test/end2end/unary/http/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ trpc_proto_library(
name = "http_rpc_proto",
srcs = ["http_rpc.proto"],
native_proto_deps = [
"@trpc_cpp//trpc/proto:trpc_options_proto",
"@com_github_trpc_protocol//trpc/proto:trpc_options_proto",
],
use_trpc_plugin = True,
)
Expand Down
20 changes: 2 additions & 18 deletions trpc/proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,8 @@ package(

proto_library(
name = "trpc_proto",
srcs = [
"trpc.proto",
],
)

proto_library(
name = "trpc_options_proto",
srcs = [
"trpc_options.proto",
],
deps = [
"@com_google_protobuf//:descriptor_proto",
],
)

cc_proto_library(
name = "cc_trpc_options_proto",
srcs = ["trpc.proto"],
deps = [
":trpc_options_proto",
"@com_github_trpc_protocol//trpc:trpc_proto",
],
)
Loading

0 comments on commit 00af5f2

Please sign in to comment.