Skip to content

Commit

Permalink
[brpc] Update to 1.2.0 and fix build error with gcc 11 (#25834)
Browse files Browse the repository at this point in the history
* [brpc] Update to 1.2.0 and fix build error with gcc 11

* x-add-version

* update portfile.cmake

* x-add-version

* add comment

* x-add-version

Co-authored-by: LilyWangLL <v-lilywang@microsoft.com>
  • Loading branch information
LilyWangLL and LilyWangLL committed Jul 20, 2022
1 parent ce9f50f commit 84541b3
Show file tree
Hide file tree
Showing 7 changed files with 673 additions and 77 deletions.
592 changes: 592 additions & 0 deletions ports/brpc/brpc-1783.diff

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ports/brpc/fix-boost-ptr.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/brpc/policy/thrift_protocol.cpp b/src/brpc/policy/thrift_protocol.cpp
index 634f8f37..21b118b1 100755
index 9871c01..269cfe1 100644
--- a/src/brpc/policy/thrift_protocol.cpp
+++ b/src/brpc/policy/thrift_protocol.cpp
@@ -45,8 +45,7 @@
Expand Down
142 changes: 70 additions & 72 deletions ports/brpc/fix-build.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 057695af..ed4979f6 100644
index 5f46dc0..fe12819 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,7 +63,8 @@ endif()
@@ -25,7 +25,7 @@ option(WITH_DEBUG_SYMBOLS "With debug symbols" ON)
option(WITH_THRIFT "With thrift framed protocol supported" OFF)
option(WITH_SNAPPY "With snappy" OFF)
option(BUILD_UNIT_TESTS "Whether to build unit tests" OFF)
-option(BUILD_BRPC_TOOLS "Whether to build brpc tools" ON)
+option(BUILD_BRPC_TOOLS "Whether to build brpc tools" OFF)
option(DOWNLOAD_GTEST "Download and build a fresh copy of googletest. Requires Internet access." ON)

# Enable MACOSX_RPATH. Run "cmake --help-policy CMP0042" for policy details.
@@ -65,7 +65,8 @@ endif()

if(WITH_THRIFT)
set(THRIFT_CPP_FLAG "-DENABLE_THRIFT_FRAMED_PROTOCOL")
Expand All @@ -12,7 +21,7 @@ index 057695af..ed4979f6 100644
endif()

include(GNUInstallDirs)
@@ -142,18 +143,21 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@@ -144,11 +145,14 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif()
endif()

Expand All @@ -21,7 +30,7 @@ index 057695af..ed4979f6 100644
+get_target_property(PROTOBUF_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES)
+set(PROTOBUF_LIBRARIES protobuf::libprotobuf)
find_package(Threads REQUIRED)
-
-find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h)
-find_library(LEVELDB_LIB NAMES leveldb)
+find_package(leveldb CONFIG REQUIRED)
Expand All @@ -30,6 +39,8 @@ index 057695af..ed4979f6 100644
if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
message(FATAL_ERROR "Fail to find leveldb")
endif()
@@ -163,8 +167,9 @@ if(WITH_SNAPPY)
endif()

if(WITH_GLOG)
- find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h)
Expand All @@ -40,7 +51,7 @@ index 057695af..ed4979f6 100644
if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB))
message(FATAL_ERROR "Fail to find glog")
endif()
@@ -171,7 +175,7 @@ if(WITH_MESALINK)
@@ -182,7 +187,7 @@ if(WITH_MESALINK)
include_directories(${MESALINK_INCLUDE_PATH})
endif()

Expand All @@ -49,7 +60,7 @@ index 057695af..ed4979f6 100644
if(NOT PROTOC_LIB)
message(FATAL_ERROR "Fail to find protoc lib")
endif()
@@ -182,7 +186,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
@@ -193,7 +198,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
)
endif()

Expand All @@ -58,7 +69,7 @@ index 057695af..ed4979f6 100644

include_directories(
${GFLAGS_INCLUDE_PATH}
@@ -197,9 +201,9 @@ set(DYNAMIC_LIB
@@ -208,9 +213,9 @@ set(DYNAMIC_LIB
${LEVELDB_LIB}
${PROTOC_LIB}
${CMAKE_THREAD_LIBS_INIT}
Expand All @@ -70,18 +81,8 @@ index 057695af..ed4979f6 100644
dl
z)

@@ -434,7 +438,9 @@ if(BUILD_UNIT_TESTS)
enable_testing()
add_subdirectory(test)
endif()
+if(BUILD_TOOLS)
add_subdirectory(tools)
+endif()

file(COPY ${CMAKE_CURRENT_BINARY_DIR}/brpc/
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/output/include/brpc/
diff --git a/cmake/FindGFLAGS.cmake b/cmake/FindGFLAGS.cmake
index dfad5fd8..83a167f0 100644
index dfad5fd..83a167f 100644
--- a/cmake/FindGFLAGS.cmake
+++ b/cmake/FindGFLAGS.cmake
@@ -15,7 +15,8 @@
Expand All @@ -104,82 +105,79 @@ index dfad5fd8..83a167f0 100644
set(GFLAGS_FOUND TRUE)
endif(GFLAGS_INCLUDE_PATH AND GFLAGS_LIBRARY)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ee616eb1..35a5b48e 100644
index 209c0e2..b9434ee 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,45 +31,77 @@ add_dependencies(SOURCES_LIB PROTO_LIB)
@@ -30,17 +30,22 @@ add_dependencies(SOURCES_LIB PROTO_LIB)
# shared library needs POSITION_INDEPENDENT_CODE
set_property(TARGET ${SOURCES_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
set_property(TARGET ${BUTIL_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)

-add_library(brpc-shared SHARED $<TARGET_OBJECTS:BUTIL_LIB>
+if (BUILD_SHARED_LIBS)
+add_library(brpc-shared SHARED $<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:SOURCES_LIB>
$<TARGET_OBJECTS:PROTO_LIB>)
+else()
-
+if(NOT BUILD_SHARED_LIBS)
add_library(brpc-static STATIC $<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:SOURCES_LIB>
$<TARGET_OBJECTS:PROTO_LIB>)

-if(BRPC_WITH_THRIFT)
+if(WITH_THRIFT)
target_link_libraries(brpc-static thrift)
endif()
-
-target_link_libraries(brpc-shared ${DYNAMIC_LIB})
+target_link_libraries(brpc-static PUBLIC ${DYNAMIC_LIB})
+if(BRPC_WITH_GLOG)
+ target_link_libraries(brpc-static ${GLOG_LIB})
+endif()
+if (BUILD_SHARED_LIBS)
+target_include_directories(brpc-shared PUBLIC $<INSTALL_INTERFACE:include>)
+target_link_libraries(brpc-shared PUBLIC ${DYNAMIC_LIB})
+else()
+target_include_directories(brpc-static PUBLIC $<INSTALL_INTERFACE:include>)
+target_link_libraries(brpc-static PUBLIC ${DYNAMIC_LIB})
SET_TARGET_PROPERTIES(brpc-static PROPERTIES OUTPUT_NAME brpc CLEAN_DIRECT_OUTPUT 1)
-
+endif()

if(BRPC_WITH_GLOG)
+ if (BUILD_SHARED_LIBS)
target_link_libraries(brpc-shared ${GLOG_LIB})
+ else()
+ target_link_libraries(brpc-static ${GLOG_LIB})
+ endif()
endif()

if(BRPC_WITH_THRIFT)
+ if (BUILD_SHARED_LIBS)
target_link_libraries(brpc-shared thrift)
+ else()
target_link_libraries(brpc-static thrift)
+ endif()
+if(0)
# for protoc-gen-mcpack
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/output/bin)

@@ -49,35 +54,56 @@ set(protoc_gen_mcpack_SOURCES
)

add_executable(protoc-gen-mcpack ${protoc_gen_mcpack_SOURCES})
-
+endif()
if(BUILD_SHARED_LIBS)
add_library(brpc-shared SHARED $<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:SOURCES_LIB>
$<TARGET_OBJECTS:PROTO_LIB>)
target_link_libraries(brpc-shared ${DYNAMIC_LIB})
+ target_include_directories(brpc-shared PUBLIC $<INSTALL_INTERFACE:include>)
if(BRPC_WITH_GLOG)
target_link_libraries(brpc-shared ${GLOG_LIB})
endif()
- if(BRPC_WITH_THRIFT)
+ if(WITH_THRIFT)
target_link_libraries(brpc-shared thrift)
endif()
SET_TARGET_PROPERTIES(brpc-shared PROPERTIES OUTPUT_NAME brpc CLEAN_DIRECT_OUTPUT 1)

target_link_libraries(protoc-gen-mcpack brpc-shared ${DYNAMIC_LIB} pthread)

- install(TARGETS brpc-shared
+ install(TARGETS brpc-shared EXPORT unofficial-brpcTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
else()
- target_link_libraries(protoc-gen-mcpack brpc-static ${BRPC_PRIVATE_LIBS} pthread)
endif()

+if (NOT BUILD_SHARED_LIBS)
SET_TARGET_PROPERTIES(brpc-static PROPERTIES OUTPUT_NAME brpc CLEAN_DIRECT_OUTPUT 1)
+else()
SET_TARGET_PROPERTIES(brpc-shared PROPERTIES OUTPUT_NAME brpc CLEAN_DIRECT_OUTPUT 1)
+endif()

-# for protoc-gen-mcpack
-set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/output/bin)
-
-set(protoc_gen_mcpack_SOURCES
- ${PROJECT_SOURCE_DIR}/src/mcpack2pb/generator.cpp
- )
-add_executable(protoc-gen-mcpack ${protoc_gen_mcpack_SOURCES})
-target_link_libraries(protoc-gen-mcpack brpc-shared)
-
#install directory
-install(TARGETS brpc-shared
+if (BUILD_SHARED_LIBS)
+install(TARGETS brpc-shared EXPORT unofficial-brpcTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-
-install(TARGETS brpc-static
+else()
+if(NOT BUILD_SHARED_LIBS)
+install(TARGETS brpc-static EXPORT unofficial-brpcTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
+endif()
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-brpc-config.cmake"
+[[include(CMakeFindDependencyMacro)
+find_dependency(OpenSSL)
Expand Down
5 changes: 3 additions & 2 deletions ports/brpc/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO apache/incubator-brpc
REF 06247c18ed6307613f04c0d2357cb91d0c14131b
SHA512 f31b1ce3bd99dd585686ec540c9713d5d5936b2d58aadfb3f0ef48faeaab1797f2373e14b73578c2f9f8355d1e9d03661e2ed9ed8c4349b4e43e510d2214b5ae
REF 29491107cbf405a494aaf80ee32344ba34e1d7e4 #1.2.0
SHA512 bd4c67967796592030903041ddb9205e24c9f196e63ebc153e08fbce723d93d27cd4f30f3c2cf904a93cda66ffa9db7d465d6e5fdac27a045ae84afad3dd1dc3
HEAD_REF master
PATCHES
fix-build.patch
fix-boost-ptr.patch
brpc-1783.diff #https://github.com/apache/incubator-brpc/pull/1783
)

vcpkg_cmake_configure(
Expand Down
2 changes: 1 addition & 1 deletion ports/brpc/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brpc",
"version": "1.1.0",
"version": "1.2.0",
"description": "Industrial-grade RPC framework used throughout Baidu, with 1,000,000+ instances and thousands kinds of services, called \"baidu-rpc\" inside Baidu.",
"homepage": "https://github.com/apache/incubator-brpc",
"license": "Apache-2.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/b-/brpc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "d75b4f1f3f1bf6072c3095fe34f29e86c19ec4d5",
"version": "1.2.0",
"port-version": 0
},
{
"git-tree": "c88bb19658430803981fbfa4ec45432bed88310b",
"version": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@
"port-version": 2
},
"brpc": {
"baseline": "1.1.0",
"baseline": "1.2.0",
"port-version": 0
},
"brunocodutra-metal": {
Expand Down

0 comments on commit 84541b3

Please sign in to comment.