Skip to content

Commit

Permalink
[grpc] Support latest version of grpc PoC (google#6338)
Browse files Browse the repository at this point in the history
* use grpcpp rather than deprecated grpc++

* grpcpp Deserialize take ByteBuffer instead of grpc_byte_buffer

* grpc 1.36.0

* Fix to use grpc 1.36.0

* Fix CMakeLists to refer gRPC

* add find_package(Threads)

* Update bazel deps

* Apply workaround about boringssl build error

* Install latest cmake for osx on travis-ci

Co-authored-by: Yeom Gyusun <[email protected]>
  • Loading branch information
youknowone and Perlmint authored Mar 25, 2021
1 parent 124654f commit 276b1bc
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 285 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ matrix:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi

script:
- pip install cmake
- bash .travis/check-sources.sh
- bash grpc/build_grpc.sh
- cmake .
Expand All @@ -125,6 +126,11 @@ matrix:
- BUILD_TYPE=Release

script:
- pip install --user cmake
- mkdir ~/cmake_path
- ln -s $(find ~/Library/Python -name cmake -type f | head -n 1) ~/cmake_path/cmake
- ln -s $(find ~/Library/Python -name ctest -type f | head -n 1) ~/cmake_path/ctest
- export PATH=~/cmake_path:${PATH}
- bash grpc/build_grpc.sh
- cmake .
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,13 @@ if(FLATBUFFERS_BUILD_GRPCTEST)
endif()
INCLUDE_DIRECTORIES(${GRPC_INSTALL_PATH}/include)
INCLUDE_DIRECTORIES(${PROTOBUF_DOWNLOAD_PATH}/src)
LINK_DIRECTORIES(${GRPC_INSTALL_PATH}/lib)
find_package(Threads REQUIRED)
list(APPEND CMAKE_PREFIX_PATH ${GRPC_INSTALL_PATH})
find_package(protobuf CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
add_dependencies(grpctest generated_code)
target_link_libraries(grpctest PRIVATE grpc++_unsecure grpc_unsecure gpr pthread dl)
target_link_libraries(grpctest PRIVATE gRPC::grpc++_unsecure gRPC::grpc_unsecure gRPC::gpr pthread dl)
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
# GRPC test has problems with alignment and will fail under ASAN/UBSAN.
# add_fsanitize_to_target(grpctest ${FLATBUFFERS_CODE_SANITIZE})
Expand Down
17 changes: 6 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,29 @@ go_rules_dependencies()
go_register_toolchains()

##### Protobuf
_PROTOBUF_VERSION = "3.6.1"
_PROTOBUF_VERSION = "3.15.2"

http_archive(
name = "com_google_protobuf",
patch_args = ["-p1"],
patches = [
"//bazel:protobuf_deps_3_6_1.patch",
],
strip_prefix = "protobuf-" + _PROTOBUF_VERSION,
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v" + _PROTOBUF_VERSION + ".tar.gz",
],
)

##### GRPC
_GRPC_VERSION = "1.15.1"
_GRPC_VERSION = "1.36.1"

http_archive(
name = "com_github_grpc_grpc",
patch_args = ["-p1"],
patches = [
"//bazel:grpc_deps_1_15_1.patch",
"//bazel:grpc_deps_1_15_1_02.patch",
],
strip_prefix = "grpc-" + _GRPC_VERSION,
urls = ["https://github.com/grpc/grpc/archive/v" + _GRPC_VERSION + ".tar.gz"],
)

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()

load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()
155 changes: 0 additions & 155 deletions bazel/grpc_deps_1_15_1.patch

This file was deleted.

48 changes: 0 additions & 48 deletions bazel/grpc_deps_1_15_1_02.patch

This file was deleted.

24 changes: 0 additions & 24 deletions bazel/protobuf_deps_3_6_1.patch

This file was deleted.

13 changes: 13 additions & 0 deletions grpc/boringssl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1645a264a..12f8ca999 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -635,6 +635,8 @@ add_library(
src/ssl/tls_record.cc
)

+target_link_libraries(ssl crypto)
+
add_executable(
bssl

14 changes: 10 additions & 4 deletions grpc/build_grpc.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#!/bin/bash

grpc_1_15_1_githash=1a60e6971f428323245a930031ad267bb3142ba4
grpc_1_36_0_githash=736e3758351ced3cd842bad3ba4e2540f01bbc48

function build_grpc () {
git clone https://github.com/grpc/grpc.git google/grpc
cd google/grpc
git checkout ${grpc_1_15_1_githash}
git checkout ${grpc_1_36_0_githash}
git submodule update --init
make
make install prefix=`pwd`/install
# Apply boringssl build patch
cd third_party/boringssl-with-bazel
git apply ../../../../grpc/boringssl.patch
cd ../..
mkdir ../grpc_build
cd ../grpc_build
cmake ../grpc -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=`pwd`/../grpc/install
cmake --build . --target install ${JOBS:+-j$JOBS}
if [ ! -f ${GRPC_INSTALL_PATH}/lib/libgrpc++_unsecure.so.1 ]; then
ln -s ${GRPC_INSTALL_PATH}/lib/libgrpc++_unsecure.so.6 ${GRPC_INSTALL_PATH}/lib/libgrpc++_unsecure.so.1
fi
Expand Down
2 changes: 1 addition & 1 deletion grpc/samples/greeter/client.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "greeter.grpc.fb.h"
#include "greeter_generated.h"

#include <grpc++/grpc++.h>
#include <grpcpp/grpcpp.h>

#include <iostream>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion grpc/samples/greeter/server.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "greeter.grpc.fb.h"
#include "greeter_generated.h"

#include <grpc++/grpc++.h>
#include <grpcpp/grpcpp.h>

#include <iostream>
#include <memory>
Expand Down
Loading

0 comments on commit 276b1bc

Please sign in to comment.