This is an automated email from the ASF dual-hosted git repository. chhsiao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 200ed1d83c80f2c21ba04e25b2248f40c30b234a Author: Chun-Hung Hsiao <chhs...@mesosphere.io> AuthorDate: Fri Jul 27 12:00:01 2018 -0700 Always build gRPC in libprocess. Review: https://reviews.apache.org/r/68091 --- 3rdparty/libprocess/3rdparty/Makefile.am | 2 - 3rdparty/libprocess/Makefile.am | 28 +++----- 3rdparty/libprocess/configure.ac | 96 +++++++++++++--------------- 3rdparty/libprocess/src/CMakeLists.txt | 8 +-- 3rdparty/libprocess/src/tests/CMakeLists.txt | 42 ++++++------ 5 files changed, 75 insertions(+), 101 deletions(-) diff --git a/3rdparty/libprocess/3rdparty/Makefile.am b/3rdparty/libprocess/3rdparty/Makefile.am index a0c7f38..5541419 100644 --- a/3rdparty/libprocess/3rdparty/Makefile.am +++ b/3rdparty/libprocess/3rdparty/Makefile.am @@ -209,7 +209,6 @@ PROTOBUF_LINKER_FLAGS = @PROTOBUF_LINKERFLAGS@ PROTOC = @PROTOCOMPILER@ endif -if ENABLE_GRPC if !ENABLE_SSL GRPC_VARIANT = _unsecure endif @@ -254,7 +253,6 @@ else $(GRPC)-build-stamp: touch $@ endif -endif # Convenience library for gmock/gtest. check_LTLIBRARIES = libgmock.la diff --git a/3rdparty/libprocess/Makefile.am b/3rdparty/libprocess/Makefile.am index abf6673..f9d9d06 100644 --- a/3rdparty/libprocess/Makefile.am +++ b/3rdparty/libprocess/Makefile.am @@ -113,7 +113,6 @@ $(LIB_GPERFTOOLS): $(GPERFTOOLS)-build-stamp BUNDLED_DEPS += $(GPERFTOOLS)-build-stamp endif -if ENABLE_GRPC if !ENABLE_SSL GRPC_VARIANT = _unsecure endif @@ -136,7 +135,6 @@ else LIB_GRPC = -lgrpc++$(GRPC_VARIANT) -lgrpc$(GRPC_VARIANT) -lgpr GRPC_CPP_PLUGIN = @GRPC_CXX_PLUGIN@ endif -endif if WITH_BUNDLED_HTTP_PARSER HTTP_PARSER_INCLUDE_FLAGS = -I$(HTTP_PARSER) @@ -204,6 +202,7 @@ libprocess_la_SOURCES = \ src/event_queue.hpp \ src/firewall.cpp \ src/gate.hpp \ + src/grpc.cpp \ src/gtest_constants.cpp \ src/help.cpp \ src/http.cpp \ @@ -265,11 +264,6 @@ libprocess_la_CPPFLAGS = \ $(STOUT_INCLUDE_FLAGS) \ $(AM_CPPFLAGS) -if ENABLE_GRPC -libprocess_la_SOURCES += \ - src/grpc.cpp -endif - if ENABLE_LIBEVENT libprocess_la_SOURCES += \ src/posix/libevent/libevent.hpp \ @@ -309,6 +303,8 @@ libprocess_tests_SOURCES = \ src/tests/decoder_tests.cpp \ src/tests/encoder_tests.cpp \ src/tests/future_tests.cpp \ + src/tests/grpc_tests.cpp \ + src/tests/grpc_tests.proto \ src/tests/http_tests.cpp \ src/tests/io_tests.cpp \ src/tests/limiter_tests.cpp \ @@ -333,6 +329,12 @@ libprocess_tests_SOURCES = \ src/tests/timeseries_tests.cpp \ src/tests/time_tests.cpp +GRPC_TESTS_PROTOS = \ + grpc_tests.grpc.pb.cc \ + grpc_tests.grpc.pb.h \ + grpc_tests.pb.cc \ + grpc_tests.pb.h + libprocess_tests_CPPFLAGS = \ -I$(srcdir)/src \ $(GMOCK_INCLUDE_FLAGS) \ @@ -345,18 +347,6 @@ libprocess_tests_LDADD = \ $(LIB_PROTOBUF) \ libprocess.la -if ENABLE_GRPC -libprocess_tests_SOURCES += \ - src/tests/grpc_tests.cpp \ - src/tests/grpc_tests.proto - -GRPC_TESTS_PROTOS = \ - grpc_tests.grpc.pb.cc \ - grpc_tests.grpc.pb.h \ - grpc_tests.pb.cc \ - grpc_tests.pb.h -endif - if ENABLE_SSL check_PROGRAMS += ssl-client ssl_client_SOURCES = src/tests/ssl_client.cpp diff --git a/3rdparty/libprocess/configure.ac b/3rdparty/libprocess/configure.ac index f125e43..752d5ba 100644 --- a/3rdparty/libprocess/configure.ac +++ b/3rdparty/libprocess/configure.ac @@ -105,11 +105,6 @@ AC_ARG_ENABLE([debug], option won't change them default: no]), [], [enable_debug=no]) -AC_ARG_ENABLE([grpc], - AS_HELP_STRING([--enable-grpc], - [enable grpc support]), - [], [enable_grpc=no]) - AC_ARG_ENABLE([install], AS_HELP_STRING([--enable-install], [install libprocess]), @@ -1188,52 +1183,51 @@ location of protobuf used by grpc by providing a prefix path via LDFLAGS="$LDFLAGS -L${with_grpc}/lib" fi -if test "x$enable_grpc" = "xyes"; then - # Check if user has asked us to use a preinstalled grpc, or if they - # asked us to ignore all bundled libraries while compiling and linking. - if test "x$without_bundled_grpc" = "xyes" || \ - test "x$enable_bundled" != "xyes"; then - # Use the system default prefix if not specified. - if test -n "`echo $with_grpc`"; then - GRPCPREFIX="${with_grpc}" - elif test "x$enable_bundled" != "xyes"; then - GRPCPREFIX="/usr" - fi - - if test "x$enable_ssl" = "xno"; then - GRPC_VARIANT="_unsecure" - fi - - # Check if headers and library were located. - saved_LIBS="$LIBS" - LIBS="-lgrpc++$GRPC_VARIANT -lgrpc$GRPC_VARIANT -lgpr $LIBS" - AC_LANG_PUSH([C++]) - AC_CHECK_HEADERS([grpcpp/grpcpp.h], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM([#include <grpcpp/grpcpp.h>], - [grpc::Version();])], - [found_grpc=yes], - [found_grpc=no])], - [found_grpc=no]) - AC_LANG_POP() - LIBS="$saved_LIBS" - - if test "x$found_grpc" = "xyes"; then - with_bundled_grpc=no +# Check if user has asked us to use a preinstalled grpc, or if they +# asked us to ignore all bundled libraries while compiling and linking. +if test "x$without_bundled_grpc" = "xyes" || \ + test "x$enable_bundled" != "xyes"; then + # Use the system default prefix if not specified. + if test -n "`echo $with_grpc`"; then + GRPCPREFIX="${with_grpc}" + elif test "x$enable_bundled" != "xyes"; then + GRPCPREFIX="/usr" + fi - AC_CHECK_TOOL([GRPC_CXX_PLUGIN_TEST], - [grpc_cpp_plugin], - [], - [$GRPCPREFIX/bin]) + if test "x$enable_ssl" = "xno"; then + GRPC_VARIANT="_unsecure" + fi - if test -z "`echo $GRPC_CXX_PLUGIN_TEST`"; then - AC_MSG_ERROR([grpc_cpp_plugin not found in PATH]) - fi + # Check if headers and library were located. + saved_LIBS="$LIBS" + LIBS="-lgrpc++$GRPC_VARIANT -lgrpc$GRPC_VARIANT -lgpr $LIBS" + AC_LANG_PUSH([C++]) + AC_CHECK_HEADERS([grpcpp/grpcpp.h], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include <grpcpp/grpcpp.h>], + [grpc::Version();])], + [found_grpc=yes], + [found_grpc=no])], + [found_grpc=no]) + AC_LANG_POP() + LIBS="$saved_LIBS" + + if test "x$found_grpc" = "xyes"; then + with_bundled_grpc=no + + AC_CHECK_TOOL([GRPC_CXX_PLUGIN_TEST], + [grpc_cpp_plugin], + [], + [$GRPCPREFIX/bin]) + + if test -z "`echo $GRPC_CXX_PLUGIN_TEST`"; then + AC_MSG_ERROR([grpc_cpp_plugin not found in PATH]) + fi - GRPC_CXX_PLUGIN="$GRPCPREFIX/bin/grpc_cpp_plugin" + GRPC_CXX_PLUGIN="$GRPCPREFIX/bin/grpc_cpp_plugin" - else - AC_MSG_ERROR([cannot find grpc + else + AC_MSG_ERROR([cannot find grpc ------------------------------------------------------------------- You have requested the use of a non-bundled grpc but no suitable grpc could be found. @@ -1242,14 +1236,12 @@ You may want specify the location of grpc by providing a prefix path via --with-grpc=DIR, or check that the path you provided is correct if you are already doing this. ------------------------------------------------------------------- - ]) - fi - else - with_bundled_grpc=yes + ]) fi +else + with_bundled_grpc=yes fi -AM_CONDITIONAL([ENABLE_GRPC], [test "x$enable_grpc" = "xyes"]) AM_CONDITIONAL([WITH_BUNDLED_GRPC], [test "x$with_bundled_grpc" = "xyes"]) diff --git a/3rdparty/libprocess/src/CMakeLists.txt b/3rdparty/libprocess/src/CMakeLists.txt index bb8af6d..19fa980 100644 --- a/3rdparty/libprocess/src/CMakeLists.txt +++ b/3rdparty/libprocess/src/CMakeLists.txt @@ -29,6 +29,7 @@ set(PROCESS_SRC authenticator_manager.cpp clock.cpp firewall.cpp + grpc.cpp gtest_constants.cpp help.cpp http.cpp @@ -56,11 +57,6 @@ else () posix/subprocess.cpp) endif () -if (ENABLE_GRPC) - list(APPEND PROCESS_SRC - grpc.cpp) -endif () - if (ENABLE_LIBEVENT) list(APPEND PROCESS_SRC posix/libevent/libevent.cpp @@ -104,7 +100,7 @@ target_link_libraries( process PUBLIC stout http_parser - $<$<BOOL:${ENABLE_GRPC}>:grpc> + grpc $<$<BOOL:${ENABLE_SSL}>:OpenSSL::SSL> $<$<BOOL:${ENABLE_SSL}>:OpenSSL::Crypto>) diff --git a/3rdparty/libprocess/src/tests/CMakeLists.txt b/3rdparty/libprocess/src/tests/CMakeLists.txt index 5814bc6..a03a77e 100644 --- a/3rdparty/libprocess/src/tests/CMakeLists.txt +++ b/3rdparty/libprocess/src/tests/CMakeLists.txt @@ -24,6 +24,7 @@ set(PROCESS_TESTS_SRC decoder_tests.cpp encoder_tests.cpp future_tests.cpp + grpc_tests.cpp http_tests.cpp limiter_tests.cpp loop_tests.cpp @@ -45,6 +46,25 @@ set(PROCESS_TESTS_SRC time_tests.cpp timeseries_tests.cpp) +set(GRPC_TESTS_PROTOS + grpc_tests.grpc.pb.cc + grpc_tests.grpc.pb.h + grpc_tests.pb.cc + grpc_tests.pb.h) + +list(APPEND PROCESS_TESTS_SRC + ${GRPC_TESTS_PROTOS}) + +add_custom_command( + OUTPUT ${GRPC_TESTS_PROTOS} + COMMAND protoc + -I${CMAKE_CURRENT_SOURCE_DIR} + --cpp_out=${CMAKE_CURRENT_BINARY_DIR} + --grpc_out=${CMAKE_CURRENT_BINARY_DIR} + --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin> + ${CMAKE_CURRENT_SOURCE_DIR}/grpc_tests.proto + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/grpc_tests.proto) + if (NOT WIN32) list(APPEND PROCESS_TESTS_SRC io_tests.cpp @@ -54,28 +74,6 @@ elseif (ENABLE_LIBWINIO) io_tests.cpp) endif () -if (ENABLE_GRPC) - set(GRPC_TESTS_PROTOS - grpc_tests.grpc.pb.cc - grpc_tests.grpc.pb.h - grpc_tests.pb.cc - grpc_tests.pb.h) - - list(APPEND PROCESS_TESTS_SRC - grpc_tests.cpp - ${GRPC_TESTS_PROTOS}) - - add_custom_command( - OUTPUT ${GRPC_TESTS_PROTOS} - COMMAND protoc - -I${CMAKE_CURRENT_SOURCE_DIR} - --cpp_out=${CMAKE_CURRENT_BINARY_DIR} - --grpc_out=${CMAKE_CURRENT_BINARY_DIR} - --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin> - ${CMAKE_CURRENT_SOURCE_DIR}/grpc_tests.proto - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/grpc_tests.proto) -endif () - if (ENABLE_SSL) list(APPEND PROCESS_TESTS_SRC jwt_tests.cpp