Merge branch 'master' into removsched

pull/20892/head
Yash Tibrewal 5 years ago
commit 4ffda62d7d
  1. 17186
      CMakeLists.txt
  2. 6
      bazel/grpc_deps.bzl
  3. 16
      cmake/benchmark.cmake
  4. 4
      cmake/cares.cmake
  5. 16
      cmake/gRPCConfig.cmake.in
  6. 11
      cmake/gRPCConfigVersion.cmake.in
  7. 4
      cmake/gflags.cmake
  8. 8
      cmake/msvc_static_runtime.cmake
  9. 6
      cmake/protobuf.cmake
  10. 6
      cmake/ssl.cmake
  11. 6
      cmake/zlib.cmake
  12. 14
      doc/core/grpc-polling-engines.md
  13. 11
      examples/objective-c/helloworld/main.m
  14. 3
      examples/objective-c/helloworld_macos/main.m
  15. 10
      examples/objective-c/route_guide/ViewControllers.m
  16. 40
      src/core/ext/filters/client_channel/http_connect_handshaker.cc
  17. 9
      src/core/lib/iomgr/buffer_list.cc
  18. 20
      src/core/lib/iomgr/tcp_posix.cc
  19. 45
      src/core/lib/security/transport/security_handshaker.cc
  20. 12
      src/core/lib/surface/call.cc
  21. 30
      src/python/grpcio/grpc/__init__.py
  22. 12
      src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi
  23. 1
      src/python/grpcio_tests/commands.py
  24. 1
      src/python/grpcio_tests/tests/tests.json
  25. 1
      src/python/grpcio_tests/tests/unit/BUILD.bazel
  26. 54
      src/python/grpcio_tests/tests/unit/_grpc_shutdown_test.py
  27. 238
      templates/CMakeLists.txt.template
  28. 34
      test/core/iomgr/endpoint_tests.cc
  29. 2
      test/core/iomgr/tcp_posix_test.cc
  30. 63
      test/distrib/cpp/run_distrib_test_cmake.bat
  31. 56
      test/distrib/cpp/run_distrib_test_cmake.sh
  32. 51
      test/distrib/cpp/run_distrib_test_cmake_pkgconfig.sh
  33. 2
      third_party/abseil-cpp
  34. 2
      third_party/objective_c/google_toolbox_for_mac/BUILD
  35. 4
      third_party/py/python_configure.bzl
  36. 12
      tools/internal_ci/macos/grpc_run_bazel_cpp_ios_tests.sh
  37. 2
      tools/run_tests/helper_scripts/build_python.sh
  38. 4
      tools/run_tests/run_tests.py
  39. 2
      tools/run_tests/sanity/check_submodules.sh

File diff suppressed because it is too large Load Diff

@ -165,9 +165,9 @@ def grpc_deps():
if "com_google_absl" not in native.existing_rules():
http_archive(
name = "com_google_absl",
sha256 = "fd4edc10767c28b23bf9f41114c6bcd9625c165a31baa0e6939f01058029a912",
strip_prefix = "abseil-cpp-74d91756c11bc22f9b0108b94da9326f7f9e376f",
url = "https://github.com/abseil/abseil-cpp/archive/74d91756c11bc22f9b0108b94da9326f7f9e376f.tar.gz",
sha256 = "c5f6429c067e6b8f3c6d13d1ab2bdcd559c6f8b85317aa5b0dc8c364c37d1742",
strip_prefix = "abseil-cpp-846e5dbedac123d12455adcfe6f53c8b5dcbfeef",
url = "https://github.com/abseil/abseil-cpp/archive/846e5dbedac123d12455adcfe6f53c8b5dcbfeef.tar.gz",
)
if "bazel_toolchains" not in native.existing_rules():

@ -12,21 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "module")
if(gRPC_BENCHMARK_PROVIDER STREQUAL "module")
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Turn off gTest in gBenchmark")
if(NOT BENCHMARK_ROOT_DIR)
set(BENCHMARK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/benchmark)
endif()
if(EXISTS "${BENCHMARK_ROOT_DIR}/CMakeLists.txt")
add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark)
if(TARGET benchmark)
set(_gRPC_BENCHMARK_LIBRARIES benchmark)
set(_gRPC_BENCHMARK_INCLUDE_DIR "${BENCHMARK_ROOT_DIR}/include")
endif()
add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark)
if(TARGET benchmark)
set(_gRPC_BENCHMARK_LIBRARIES benchmark)
set(_gRPC_BENCHMARK_INCLUDE_DIR "${BENCHMARK_ROOT_DIR}/include")
endif()
else()
message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
endif()
elseif("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "package")
elseif(gRPC_BENCHMARK_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for benchmark.
find_package(benchmark REQUIRED CONFIG)
if(TARGET benchmark::benchmark)

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
if(gRPC_CARES_PROVIDER STREQUAL "module")
if(NOT CARES_ROOT_DIR)
set(CARES_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares)
endif()
@ -33,7 +33,7 @@ if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE)
endif()
elseif("${gRPC_CARES_PROVIDER}" STREQUAL "package")
elseif(gRPC_CARES_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for c-ares.
find_package(c-ares REQUIRED CONFIG)
if(TARGET c-ares::cares)

@ -1,8 +1,8 @@
# Depend packages
@_gRPC_FIND_ZLIB@
@_gRPC_FIND_PROTOBUF@
@_gRPC_FIND_SSL@
@_gRPC_FIND_CARES@
# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)
# Depend packages
@_gRPC_FIND_ZLIB@
@_gRPC_FIND_PROTOBUF@
@_gRPC_FIND_SSL@
@_gRPC_FIND_CARES@
# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)

@ -1,11 +0,0 @@
set(PACKAGE_VERSION "@PACKAGE_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module")
if(gRPC_GFLAGS_PROVIDER STREQUAL "module")
if(NOT GFLAGS_ROOT_DIR)
set(GFLAGS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags)
endif()
@ -23,7 +23,7 @@ if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module")
else()
message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong")
endif()
elseif("${gRPC_GFLAGS_PROVIDER}" STREQUAL "package")
elseif(gRPC_GFLAGS_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for gflags.
find_package(gflags REQUIRED CONFIG)
if(TARGET gflags::gflags)

@ -22,9 +22,9 @@ if(gRPC_MSVC_STATIC_RUNTIME)
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
if(flag_var MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
if(gRPC_PROTOBUF_PROVIDER STREQUAL "module")
# Building the protobuf tests require gmock what is not part of a standard protobuf checkout.
# Disable them unless they are explicitly requested from the cmake command line (when we assume
# gmock is downloaded to the right location inside protobuf).
@ -45,13 +45,13 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
# For well-known .proto files distributed with protobuf
set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}/src")
else()
message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong")
message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE)
endif()
elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package")
elseif(gRPC_PROTOBUF_PROVIDER STREQUAL "package")
find_package(Protobuf REQUIRED ${gRPC_PROTOBUF_PACKAGE_TYPE})
# {Protobuf,PROTOBUF}_FOUND is defined based on find_package type ("MODULE" vs "CONFIG").

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
if(gRPC_SSL_PROVIDER STREQUAL "module")
if(NOT BORINGSSL_ROOT_DIR)
set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl)
endif()
@ -31,13 +31,13 @@ if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include)
endif()
else()
message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE)
endif()
elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package")
elseif(gRPC_SSL_PROVIDER STREQUAL "package")
# OpenSSL installation directory can be configured by setting OPENSSL_ROOT_DIR
# We expect to locate OpenSSL using the built-in cmake module as the openssl
# project itself does not provide installation support in its CMakeLists.txt

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
if(gRPC_ZLIB_PROVIDER STREQUAL "module")
if(NOT ZLIB_ROOT_DIR)
set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
endif()
@ -26,13 +26,13 @@ if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
set(_gRPC_ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib")
endif()
else()
message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE)
endif()
elseif("${gRPC_ZLIB_PROVIDER}" STREQUAL "package")
elseif(gRPC_ZLIB_PROVIDER STREQUAL "package")
# zlib installation directory can be configured by setting ZLIB_ROOT
# We allow locating zlib using both "CONFIG" and "MODULE" as the expectation
# is that many Linux systems will have zlib installed via a distribution

@ -36,7 +36,7 @@ The following are the **Opaque** structures exposed by Polling Engine interface
- **grpc_fd:** Structure representing a file descriptor
- **grpc_pollset:** A set of one or more grpc_fds that are ‘polled’ for readable/writable/error events. One grpc_fd can be in multiple `grpc_pollset`s
- **grpc_pollset_worker:** Structure representing a ‘polling thread’ - more specifically, the thread that calls `grpc_pollset_work()` API
- **grpc_pollset_set:** A group of `grpc_fds`, `grpc_pollsets` and `grpc_pollset_sets` (yes, a `grpc_pollset_set` can contain other `grpc_pollset_sets`)
- **grpc_pollset_set:** A group of `grpc_fd`s, `grpc_pollset`s and `grpc_pollset_set`s (yes, a `grpc_pollset_set` can contain other `grpc_pollset_set`s)
### Polling engine API
@ -58,12 +58,12 @@ The following are the **Opaque** structures exposed by Polling Engine interface
#### grpc_pollset
- **grpc_pollset_add_fd **
- **grpc_pollset_add_fd**
- Signature: `grpc_pollset_add_fd(grpc_pollset* ps, grpc_fd *fd)`
- Add fd to pollset
> **NOTE**: There is no `grpc_pollset_remove_fd`. This is because calling `grpc_fd_orphan()` will effectively remove the fd from all the pollsets it’s a part of
- ** grpc_pollset_work **
- **grpc_pollset_work**
- Signature: `grpc_pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker, grpc_millis deadline)`
> **NOTE**: `grpc_pollset_work()` requires the pollset mutex to be locked before calling it. Shortly after calling `grpc_pollset_work()`, the function populates the `*worker` pointer (among other things) and releases the mutex. Once `grpc_pollset_work()` returns, the `*worker` pointer is **invalid** and should not be used anymore. See the code in `completion_queue.cc` to see how this is used.
- Poll the fds in the pollset for events AND return when ANY of the following is true:
@ -72,15 +72,15 @@ The following are the **Opaque** structures exposed by Polling Engine interface
- worker is “kicked” (see `grpc_pollset_kick` for more details)
- **grpc_pollset_kick**
- Signature: `grpc_pollset_kick(grpc_pollset* ps, grpc_pollset_worker* worker)`
- “Kick the worker” i.e Force the worker to return from grpc_pollset_work()
- If `worker == nullptr`, kick ANY worker active on that pollset
- Signature: `grpc_pollset_kick(grpc_pollset* ps, grpc_pollset_worker* worker)`
- “Kick the worker” i.e Force the worker to return from grpc_pollset_work()
- If `worker == nullptr`, kick ANY worker active on that pollset
#### grpc_pollset_set
- **grpc\_pollset\_set\_[add|del]\_fd**
- Signature: `grpc_pollset_set_[add|del]_fd(grpc_pollset_set* pss, grpc_fd *fd)`
Add/Remove fd to the `grpc_pollset_set`
- Add/Remove fd to the `grpc_pollset_set`
- **grpc\_pollset\_set_[add|del]\_pollset**
- Signature: `grpc_pollset_set_[add|del]_pollset(grpc_pollset_set* pss, grpc_pollset* ps)`

@ -21,6 +21,7 @@
#import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Tests.h>
#import <GRPCClient/GRPCTransport.h>
#if COCOAPODS
#import <HelloWorld/Helloworld.pbrpc.h>
#else
@ -55,14 +56,12 @@ int main(int argc, char * argv[]) {
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
// this example does not use TLS (secure channel); use insecure channel instead
options.transportType = GRPCTransportTypeInsecure;
options.transport = GRPCDefaultTransportImplList.core_insecure;
options.userAgentPrefix = @"HelloWorld/1.0";
GRPCUnaryProtoCall *call = [client sayHelloWithMessage:request
responseHandler:[[HLWResponseHandler alloc] init]
callOptions:options];
[call start];
[[client sayHelloWithMessage:request
responseHandler:[[HLWResponseHandler alloc] init]
callOptions:options] start];
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}

@ -20,6 +20,7 @@
#import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Tests.h>
#import <GRPCClient/GRPCTransport.h>
#if COCOAPODS
#import <HelloWorld/Helloworld.pbrpc.h>
#else
@ -54,7 +55,7 @@ int main(int argc, const char * argv[]) {
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
// this example does not use TLS (secure channel); use insecure channel instead
options.transportType = GRPCTransportTypeInsecure;
options.transport = GRPCDefaultTransportImplList.core_insecure;
options.userAgentPrefix = @"HelloWorld/1.0";
GRPCUnaryProtoCall *call = [client sayHelloWithMessage:request

@ -23,6 +23,8 @@
#import "examples/protos/RouteGuide.pbrpc.h"
#endif
#import <GRPCClient/GRPCTransport.h>
static NSString * const kHostAddress = @"localhost:50051";
/** Category to override RTGPoint's description. */
@ -123,7 +125,7 @@ static NSString * const kHostAddress = @"localhost:50051";
[super viewDidLoad];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeInsecure;
options.transport = GRPCDefaultTransportImplList.core_insecure;
_service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options];
}
@ -193,7 +195,7 @@ static NSString * const kHostAddress = @"localhost:50051";
[super viewDidLoad];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeInsecure;
options.transport = GRPCDefaultTransportImplList.core_insecure;
_service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options];
}
@ -286,7 +288,7 @@ static NSString * const kHostAddress = @"localhost:50051";
[super viewDidLoad];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeInsecure;
options.transport = GRPCDefaultTransportImplList.core_insecure;
_service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options];
}
@ -360,7 +362,7 @@ static NSString * const kHostAddress = @"localhost:50051";
[super viewDidLoad];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeInsecure;
options.transport = GRPCDefaultTransportImplList.core_insecure;
_service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options];
}

@ -58,7 +58,7 @@ class HttpConnectHandshaker : public Handshaker {
static void OnWriteDone(void* arg, grpc_error* error);
static void OnReadDone(void* arg, grpc_error* error);
gpr_mu mu_;
Mutex mu_;
bool is_shutdown_ = false;
// Endpoint and read buffer to destroy after a shutdown.
@ -78,7 +78,6 @@ class HttpConnectHandshaker : public Handshaker {
};
HttpConnectHandshaker::~HttpConnectHandshaker() {
gpr_mu_destroy(&mu_);
if (endpoint_to_destroy_ != nullptr) {
grpc_endpoint_destroy(endpoint_to_destroy_);
}
@ -131,28 +130,27 @@ void HttpConnectHandshaker::HandshakeFailedLocked(grpc_error* error) {
// Callback invoked when finished writing HTTP CONNECT request.
void HttpConnectHandshaker::OnWriteDone(void* arg, grpc_error* error) {
auto* handshaker = static_cast<HttpConnectHandshaker*>(arg);
gpr_mu_lock(&handshaker->mu_);
ReleasableMutexLock lock(&handshaker->mu_);
if (error != GRPC_ERROR_NONE || handshaker->is_shutdown_) {
// If the write failed or we're shutting down, clean up and invoke the
// callback with the error.
handshaker->HandshakeFailedLocked(GRPC_ERROR_REF(error));
gpr_mu_unlock(&handshaker->mu_);
lock.Unlock();
handshaker->Unref();
} else {
// Otherwise, read the response.
// The read callback inherits our ref to the handshaker.
lock.Unlock();
grpc_endpoint_read(handshaker->args_->endpoint,
handshaker->args_->read_buffer,
&handshaker->response_read_closure_, /*urgent=*/true);
gpr_mu_unlock(&handshaker->mu_);
}
}
// Callback invoked for reading HTTP CONNECT response.
void HttpConnectHandshaker::OnReadDone(void* arg, grpc_error* error) {
auto* handshaker = static_cast<HttpConnectHandshaker*>(arg);
gpr_mu_lock(&handshaker->mu_);
ReleasableMutexLock lock(&handshaker->mu_);
if (error != GRPC_ERROR_NONE || handshaker->is_shutdown_) {
// If the read failed or we're shutting down, clean up and invoke the
// callback with the error.
@ -204,10 +202,10 @@ void HttpConnectHandshaker::OnReadDone(void* arg, grpc_error* error) {
// at the Content-Length: header).
if (handshaker->http_parser_.state != GRPC_HTTP_BODY) {
grpc_slice_buffer_reset_and_unref_internal(handshaker->args_->read_buffer);
lock.Unlock();
grpc_endpoint_read(handshaker->args_->endpoint,
handshaker->args_->read_buffer,
&handshaker->response_read_closure_, /*urgent=*/true);
gpr_mu_unlock(&handshaker->mu_);
return;
}
// Make sure we got a 2xx response.
@ -227,7 +225,7 @@ done:
// Set shutdown to true so that subsequent calls to
// http_connect_handshaker_shutdown() do nothing.
handshaker->is_shutdown_ = true;
gpr_mu_unlock(&handshaker->mu_);
lock.Unlock();
handshaker->Unref();
}
@ -236,13 +234,14 @@ done:
//
void HttpConnectHandshaker::Shutdown(grpc_error* why) {
gpr_mu_lock(&mu_);
if (!is_shutdown_) {
is_shutdown_ = true;
grpc_endpoint_shutdown(args_->endpoint, GRPC_ERROR_REF(why));
CleanupArgsForFailureLocked();
{
MutexLock lock(&mu_);
if (!is_shutdown_) {
is_shutdown_ = true;
grpc_endpoint_shutdown(args_->endpoint, GRPC_ERROR_REF(why));
CleanupArgsForFailureLocked();
}
}
gpr_mu_unlock(&mu_);
GRPC_ERROR_UNREF(why);
}
@ -257,9 +256,10 @@ void HttpConnectHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
if (server_name == nullptr) {
// Set shutdown to true so that subsequent calls to
// http_connect_handshaker_shutdown() do nothing.
gpr_mu_lock(&mu_);
is_shutdown_ = true;
gpr_mu_unlock(&mu_);
{
MutexLock lock(&mu_);
is_shutdown_ = true;
}
ExecCtx::Run(DEBUG_LOCATION, on_handshake_done, GRPC_ERROR_NONE);
return;
}
@ -290,7 +290,7 @@ void HttpConnectHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
}
}
// Save state in the handshaker object.
MutexLock lock(&mu_);
ReleasableMutexLock lock(&mu_);
args_ = args;
on_handshake_done_ = on_handshake_done;
// Log connection via proxy.
@ -320,12 +320,12 @@ void HttpConnectHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
gpr_free(header_strings);
// Take a new ref to be held by the write callback.
Ref().release();
lock.Unlock();
grpc_endpoint_write(args->endpoint, &write_buffer_, &request_done_closure_,
nullptr);
}
HttpConnectHandshaker::HttpConnectHandshaker() {
gpr_mu_init(&mu_);
grpc_slice_buffer_init(&write_buffer_);
GRPC_CLOSURE_INIT(&request_done_closure_, &HttpConnectHandshaker::OnWriteDone,
this, grpc_schedule_on_exec_ctx);

@ -293,8 +293,13 @@ void grpc_tcp_set_write_timestamps_callback(void (*fn)(void*,
#else /* GRPC_LINUX_ERRQUEUE */
namespace grpc_core {
void grpc_tcp_set_write_timestamps_callback(
void (*/*fn*/)(void*, grpc_core::Timestamps*, grpc_error* error)) {
void grpc_tcp_set_write_timestamps_callback(void (*fn)(void*,
grpc_core::Timestamps*,
grpc_error* error)) {
// Cast value of fn to void to avoid unused parameter warning.
// Can't comment out the name because some compilers and formatters don't
// like the sequence */* , which would arise from */*fn*/.
(void)fn;
gpr_log(GPR_DEBUG, "Timestamps callback is not enabled for this platform");
}
} /* namespace grpc_core */

@ -417,7 +417,7 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
tcp->read_cb = nullptr;
tcp->incoming_buffer = nullptr;
grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, error);
GRPC_CLOSURE_RUN(cb, error);
}
#define MAX_READ_IOVEC 4
@ -645,8 +645,7 @@ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
* right thing (i.e calls tcp_do_read() which either reads the available
* bytes or calls notify_on_read() to be notified when new bytes become
* available */
grpc_core::ExecCtx::Run(DEBUG_LOCATION, &tcp->read_done_closure,
GRPC_ERROR_NONE);
GRPC_CLOSURE_RUN(&tcp->read_done_closure, GRPC_ERROR_NONE);
}
}
@ -1027,7 +1026,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
if (error != GRPC_ERROR_NONE) {
cb = tcp->write_cb;
tcp->write_cb = nullptr;
grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, GRPC_ERROR_REF(error));
GRPC_CLOSURE_RUN(cb, GRPC_ERROR_REF(error));
TCP_UNREF(tcp, "write");
return;
}
@ -1076,12 +1075,11 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
tcp->outgoing_buffer_arg = arg;
if (buf->length == 0) {
grpc_core::ExecCtx::Run(
DEBUG_LOCATION, cb,
grpc_fd_is_shutdown(tcp->em_fd)
? tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"),
tcp)
: GRPC_ERROR_NONE);
GRPC_CLOSURE_RUN(cb,
grpc_fd_is_shutdown(tcp->em_fd)
? tcp_annotate_error(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"), tcp)
: GRPC_ERROR_NONE);
tcp_shutdown_buffer_list(tcp);
return;
}
@ -1103,7 +1101,7 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
const char* str = grpc_error_string(error);
gpr_log(GPR_INFO, "write: %s", str);
}
grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, error);
GRPC_CLOSURE_RUN(cb, error);
}
}

@ -66,6 +66,8 @@ class SecurityHandshaker : public Handshaker {
void HandshakeFailedLocked(grpc_error* error);
void CleanupArgsForFailureLocked();
static void ScheduleRead(void* arg, grpc_error* /* error */);
static void ScheduleWrite(void* arg, grpc_error* /* error */);
static void OnHandshakeDataReceivedFromPeerFn(void* arg, grpc_error* error);
static void OnHandshakeDataSentToPeerFn(void* arg, grpc_error* error);
static void OnHandshakeNextDoneGrpcWrapper(
@ -94,6 +96,8 @@ class SecurityHandshaker : public Handshaker {
size_t handshake_buffer_size_;
unsigned char* handshake_buffer_;
grpc_slice_buffer outgoing_;
grpc_closure schedule_read_closure_;
grpc_closure schedule_write_closure_;
grpc_closure on_handshake_data_sent_to_peer_;
grpc_closure on_handshake_data_received_from_peer_;
grpc_closure on_peer_checked_;
@ -118,6 +122,11 @@ SecurityHandshaker::SecurityHandshaker(tsi_handshaker* handshaker,
}
gpr_mu_init(&mu_);
grpc_slice_buffer_init(&outgoing_);
GRPC_CLOSURE_INIT(&schedule_read_closure_, &SecurityHandshaker::ScheduleRead,
this, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&schedule_write_closure_,
&SecurityHandshaker::ScheduleWrite, this,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&on_handshake_data_sent_to_peer_,
&SecurityHandshaker::OnHandshakeDataSentToPeerFn, this,
grpc_schedule_on_exec_ctx);
@ -199,7 +208,7 @@ void SecurityHandshaker::HandshakeFailedLocked(grpc_error* error) {
is_shutdown_ = true;
}
// Invoke callback.
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_handshake_done_, error);
ExecCtx::Run(DEBUG_LOCATION, on_handshake_done_, error);
}
void SecurityHandshaker::OnPeerCheckedInner(grpc_error* error) {
@ -259,7 +268,7 @@ void SecurityHandshaker::OnPeerCheckedInner(grpc_error* error) {
args_->args = grpc_channel_args_copy_and_add(tmp_args, &auth_context_arg, 1);
grpc_channel_args_destroy(tmp_args);
// Invoke callback.
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_handshake_done_, GRPC_ERROR_NONE);
ExecCtx::Run(DEBUG_LOCATION, on_handshake_done_, GRPC_ERROR_NONE);
// Set shutdown to true so that subsequent calls to
// security_handshaker_shutdown() do nothing.
is_shutdown_ = true;
@ -283,6 +292,19 @@ grpc_error* SecurityHandshaker::CheckPeerLocked() {
return GRPC_ERROR_NONE;
}
void SecurityHandshaker::ScheduleRead(void* arg, grpc_error* /* error */) {
SecurityHandshaker* h = static_cast<SecurityHandshaker*>(arg);
grpc_endpoint_read(h->args_->endpoint, h->args_->read_buffer,
&h->on_handshake_data_received_from_peer_,
/*urgent=*/true);
}
void SecurityHandshaker::ScheduleWrite(void* arg, grpc_error* /* error */) {
SecurityHandshaker* h = static_cast<SecurityHandshaker*>(arg);
grpc_endpoint_write(h->args_->endpoint, &h->outgoing_,
&h->on_handshake_data_sent_to_peer_, nullptr);
}
grpc_error* SecurityHandshaker::OnHandshakeNextDoneLocked(
tsi_result result, const unsigned char* bytes_to_send,
size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) {
@ -294,8 +316,7 @@ grpc_error* SecurityHandshaker::OnHandshakeNextDoneLocked(
// Read more if we need to.
if (result == TSI_INCOMPLETE_DATA) {
GPR_ASSERT(bytes_to_send_size == 0);
grpc_endpoint_read(args_->endpoint, args_->read_buffer,
&on_handshake_data_received_from_peer_, /*urgent=*/true);
ExecCtx::Run(DEBUG_LOCATION, &schedule_read_closure_, GRPC_ERROR_NONE);
return error;
}
if (result != TSI_OK) {
@ -313,12 +334,10 @@ grpc_error* SecurityHandshaker::OnHandshakeNextDoneLocked(
reinterpret_cast<const char*>(bytes_to_send), bytes_to_send_size);
grpc_slice_buffer_reset_and_unref_internal(&outgoing_);
grpc_slice_buffer_add(&outgoing_, to_send);
grpc_endpoint_write(args_->endpoint, &outgoing_,
&on_handshake_data_sent_to_peer_, nullptr);
ExecCtx::Run(DEBUG_LOCATION, &schedule_write_closure_, GRPC_ERROR_NONE);
} else if (handshaker_result == nullptr) {
// There is nothing to send, but need to read from peer.
grpc_endpoint_read(args_->endpoint, args_->read_buffer,
&on_handshake_data_received_from_peer_, /*urgent=*/true);
ExecCtx::Run(DEBUG_LOCATION, &schedule_read_closure_, GRPC_ERROR_NONE);
} else {
// Handshake has finished, check peer and so on.
error = CheckPeerLocked();
@ -393,9 +412,7 @@ void SecurityHandshaker::OnHandshakeDataSentToPeerFn(void* arg,
}
// We may be done.
if (h->handshaker_result_ == nullptr) {
grpc_endpoint_read(h->args_->endpoint, h->args_->read_buffer,
&h->on_handshake_data_received_from_peer_,
/*urgent=*/true);
ExecCtx::Run(DEBUG_LOCATION, &h->schedule_read_closure_, GRPC_ERROR_NONE);
} else {
error = h->CheckPeerLocked();
if (error != GRPC_ERROR_NONE) {
@ -449,9 +466,9 @@ class FailHandshaker : public Handshaker {
void DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
grpc_closure* on_handshake_done,
HandshakerArgs* /*args*/) override {
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_handshake_done,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to create security handshaker"));
ExecCtx::Run(DEBUG_LOCATION, on_handshake_done,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to create security handshaker"));
}
private:

@ -1224,13 +1224,8 @@ static void post_batch_completion(batch_control* bctl) {
if (bctl->completion_data.notify_tag.is_closure) {
/* unrefs error */
bctl->call = nullptr;
/* This closure may be meant to be run within some combiner. Since we aren't
* running in any combiner here, we need to use GRPC_CLOSURE_SCHED instead
* of GRPC_CLOSURE_RUN.
*/
grpc_core::ExecCtx::Run(DEBUG_LOCATION,
(grpc_closure*)bctl->completion_data.notify_tag.tag,
error);
GRPC_CLOSURE_RUN((grpc_closure*)bctl->completion_data.notify_tag.tag,
error);
GRPC_CALL_INTERNAL_UNREF(call, "completion");
} else {
/* unrefs error */
@ -1575,8 +1570,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
static_cast<grpc_cq_completion*>(
gpr_malloc(sizeof(grpc_cq_completion))));
} else {
grpc_core::ExecCtx::Run(DEBUG_LOCATION, (grpc_closure*)notify_tag,
GRPC_ERROR_NONE);
GRPC_CLOSURE_RUN((grpc_closure*)notify_tag, GRPC_ERROR_NONE);
}
error = GRPC_CALL_OK;
goto done;

@ -1765,11 +1765,18 @@ def local_channel_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP):
This is an EXPERIMENTAL API.
Local credentials are used by local TCP endpoints (e.g. localhost:10000)
also UDS connections. It allows them to create secure channel, hence
transmitting call credentials become possible.
also UDS connections.
It is useful for 1) eliminating insecure_channel usage; 2) enable unit
testing for call credentials without setting up secrets.
The connections created by local channel credentials are not
encrypted, but will be checked if they are local or not.
The UDS connections are considered secure by providing peer authentication
and data confidentiality while TCP connections are considered insecure.
It is allowed to transmit call credentials over connections created by
local channel credentials.
Local channel credentials are useful for 1) eliminating insecure_channel usage;
2) enable unit testing for call credentials without setting up secrets.
Args:
local_connect_type: Local connection type (either
@ -1788,11 +1795,18 @@ def local_server_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP):
This is an EXPERIMENTAL API.
Local credentials are used by local TCP endpoints (e.g. localhost:10000)
also UDS connections. It allows them to create secure channel, hence
transmitting call credentials become possible.
also UDS connections.
The connections created by local server credentials are not
encrypted, but will be checked if they are local or not.
The UDS connections are considered secure by providing peer authentication
and data confidentiality while TCP connections are considered insecure.
It is allowed to transmit call credentials over connections created by local
server credentials.
It is useful for 1) eliminating insecure_channel usage; 2) enable unit
testing for call credentials without setting up secrets.
Local server credentials are useful for 1) eliminating insecure_channel usage;
2) enable unit testing for call credentials without setting up secrets.
Args:
local_connect_type: Local connection type (either

@ -32,12 +32,16 @@ def _spawn_greenlet(*args):
cdef class SocketWrapper:
def __cinit__(self):
fork_handlers_and_grpc_init()
self.sockopts = []
self.socket = None
self.c_socket = NULL
self.c_buffer = NULL
self.len = 0
def __dealloc__(self):
grpc_shutdown_blocking()
cdef grpc_error* socket_init(grpc_custom_socket* socket, int domain) with gil:
sw = SocketWrapper()
sw.c_socket = socket
@ -258,10 +262,14 @@ cdef void socket_accept(grpc_custom_socket* socket, grpc_custom_socket* client,
cdef class ResolveWrapper:
def __cinit__(self):
fork_handlers_and_grpc_init()
self.c_resolver = NULL
self.c_host = NULL
self.c_port = NULL
def __dealloc__(self):
grpc_shutdown_blocking()
cdef socket_resolve_async_cython(ResolveWrapper resolve_wrapper):
try:
res = gevent_socket.getaddrinfo(resolve_wrapper.c_host, resolve_wrapper.c_port)
@ -298,6 +306,7 @@ cdef grpc_error* socket_resolve(char* host, char* port,
cdef class TimerWrapper:
def __cinit__(self, deadline):
fork_handlers_and_grpc_init()
self.timer = gevent_hub.get_hub().loop.timer(deadline)
self.event = None
@ -314,6 +323,9 @@ cdef class TimerWrapper:
self.event.set()
self.timer.stop()
def __dealloc__(self):
grpc_shutdown_blocking()
cdef void timer_start(grpc_custom_timer* t) with gil:
timer = TimerWrapper(t.timeout_ms / 1000.0)
timer.c_timer = t

@ -188,6 +188,7 @@ class TestGevent(setuptools.Command):
'unit._cython._channel_test.ChannelTest.test_negative_deadline_connectivity',
# TODO(https://github.com/grpc/grpc/issues/15411) enable this test
'unit._local_credentials_test.LocalCredentialsTest',
'testing._time_test.StrictRealTimeTest',
)
BANNED_WINDOWS_TESTS = (
# TODO(https://github.com/grpc/grpc/pull/15411) enable this test

@ -50,6 +50,7 @@
"unit._empty_message_test.EmptyMessageTest",
"unit._error_message_encoding_test.ErrorMessageEncodingTest",
"unit._exit_test.ExitTest",
"unit._grpc_shutdown_test.GrpcShutdownTest",
"unit._interceptor_test.InterceptorTest",
"unit._invalid_metadata_test.InvalidMetadataTest",
"unit._invocation_defects_test.InvocationDefectsTest",

@ -18,6 +18,7 @@ GRPCIO_TESTS_UNIT = [
"_empty_message_test.py",
"_error_message_encoding_test.py",
"_exit_test.py",
"_grpc_shutdown_test.py",
"_interceptor_test.py",
"_invalid_metadata_test.py",
"_invocation_defects_test.py",

@ -0,0 +1,54 @@
# Copyright 2019 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests the gRPC Core shutdown path."""
import time
import threading
import unittest
import datetime
import grpc
_TIMEOUT_FOR_SEGFAULT = datetime.timedelta(seconds=10)
class GrpcShutdownTest(unittest.TestCase):
def test_channel_close_with_connectivity_watcher(self):
"""Originated by https://github.com/grpc/grpc/issues/20299.
The grpc_shutdown happens synchronously, but there might be Core object
references left in Cython which might lead to ABORT or SIGSEGV.
"""
connection_failed = threading.Event()
def on_state_change(state):
if state in (grpc.ChannelConnectivity.TRANSIENT_FAILURE,
grpc.ChannelConnectivity.SHUTDOWN):
connection_failed.set()
# Connects to an void address, and subscribes state changes
channel = grpc.insecure_channel("0.1.1.1:12345")
channel.subscribe(on_state_change, True)
deadline = datetime.datetime.now() + _TIMEOUT_FOR_SEGFAULT
while datetime.datetime.now() < deadline:
time.sleep(0.1)
if connection_failed.is_set():
channel.close()
if __name__ == '__main__':
unittest.main(verbosity=2)

@ -61,12 +61,43 @@
if all(platform in platforms for platform in ['linux', 'mac', 'posix', 'windows']):
return ''
cond = ' OR '.join(['_gRPC_PLATFORM_%s' % platform.upper() for platform in platforms])
return 'if(%s)\n' % cond
return 'if(%s)' % cond
def get_platforms_condition_end(platforms):
if not get_platforms_condition_begin(platforms):
return ''
return 'endif()\n'
return 'endif()'
def platforms_condition_block(platforms):
def _func(text):
lines = text.split('\n')
cond = get_platforms_condition_begin(platforms)
if cond:
# Remove empty line following <%block>
del lines[0]
# Indent each line after
for i, line in enumerate(lines[:-1]):
if line:
lines[i] = ' ' + line
# Add the condition block
lines.insert(0, cond)
# Add endif() to the last line
lines[-1] += 'endif()'
else:
# Remove empty line following <%block>
del lines[0]
# Strip leading whitespace from first line
lines[0] = lines[0].lstrip(' ')
# Remove empty line before </%block>
del lines[-1]
return '\n'.join(lines)
return _func
%>
<%
# These files are added to a set so that they are not duplicated if multiple
@ -112,7 +143,7 @@
option(gRPC_BACKWARDS_COMPATIBILITY_MODE "Build libraries that are binary compatible across a larger number of OS and libc versions" OFF)
set(gRPC_INSTALL_default ON)
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# Disable gRPC_INSTALL by default if building as a submodule
set(gRPC_INSTALL_default OFF)
endif()
@ -122,7 +153,7 @@
# Providers for third-party dependencies (gRPC_*_PROVIDER properties):
# "module": build the dependency using sources from git submodule (under third_party)
# "package": use cmake's find_package functionality to locate a pre-installed dependency
set(gRPC_ZLIB_PROVIDER "module" CACHE STRING "Provider of zlib library")
set_property(CACHE gRPC_ZLIB_PROVIDER PROPERTY STRINGS "module" "package")
@ -165,8 +196,8 @@
## Some libraries are shared even with BUILD_SHARED_LIBRARIES=OFF
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
if (MSVC)
if(MSVC)
include(cmake/msvc_static_runtime.cmake)
add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
# needed to compile protobuf
@ -181,7 +212,7 @@
set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS} ${_gRPC_C_CXX_FLAGS}</%text>")
set(CMAKE_CXX_FLAGS "<%text>${CMAKE_CXX_FLAGS} ${_gRPC_C_CXX_FLAGS}</%text>")
if (gRPC_USE_PROTO_LITE)
if(gRPC_USE_PROTO_LITE)
set(_gRPC_PROTOBUF_LIBRARY_NAME "libprotobuf-lite")
add_definitions("-DGRPC_USE_PROTO_LITE")
else()
@ -190,13 +221,13 @@
if(gRPC_BACKWARDS_COMPATIBILITY_MODE)
add_definitions(-DGPR_BACKWARDS_COMPATIBILITY_MODE)
if (_gRPC_PLATFORM_MAC)
if(_gRPC_PLATFORM_MAC)
# some C++11 constructs not supported before OS X 10.9
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
endif()
endif()
if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS)
set(_gRPC_CORE_NOSTDCXX_FLAGS -fno-exceptions -fno-rtti)
else()
set(_gRPC_CORE_NOSTDCXX_FLAGS "")
@ -259,9 +290,9 @@
#if cross-compiling, find host plugin
if(CMAKE_CROSSCOMPILING)
find_program(_gRPC_CPP_PLUGIN grpc_cpp_plugin)
find_program(_gRPC_CPP_PLUGIN grpc_cpp_plugin)
else()
set(_gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
set(_gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
endif()
add_custom_command(
@ -280,8 +311,6 @@
WORKING_DIRECTORY <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
COMMENT "Running gRPC C++ protocol buffer compiler on <%text>${FIL}</%text>"
VERBATIM)
<%text>set_source_files_properties("${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc" "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h" "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h" "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc" "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h" PROPERTIES GENERATED TRUE)</%text>
endforeach()
endfunction()
@ -321,57 +350,57 @@
)
% endfor
if (gRPC_BUILD_TESTS)
add_custom_target(buildtests_c)
% for tgt in targets:
% if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
${get_platforms_condition_begin(tgt.platforms)}\
add_dependencies(buildtests_c ${tgt.name})
${get_platforms_condition_end(tgt.platforms)}\
% endif
% endfor
add_custom_target(buildtests_cxx)
% for tgt in targets:
% if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
${get_platforms_condition_begin(tgt.platforms)}\
add_dependencies(buildtests_cxx ${tgt.name})
${get_platforms_condition_end(tgt.platforms)}\
% endif
% endfor
if(gRPC_BUILD_TESTS)
add_custom_target(buildtests_c)
% for tgt in targets:
% if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
<%block filter='platforms_condition_block(tgt.platforms)'>
add_dependencies(buildtests_c ${tgt.name})
</%block>
% endif
% endfor
add_custom_target(buildtests_cxx)
% for tgt in targets:
% if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
<%block filter='platforms_condition_block(tgt.platforms)'>
add_dependencies(buildtests_cxx ${tgt.name})
</%block>
% endif
% endfor
add_custom_target(buildtests
DEPENDS buildtests_c buildtests_cxx)
endif (gRPC_BUILD_TESTS)
add_custom_target(buildtests
DEPENDS buildtests_c buildtests_cxx)
endif()
% for lib in libs:
% if lib.build in ["all", "protoc", "tool", "test", "private"] and not lib.boringssl:
% if not lib.get('build_system', []) or 'cmake' in lib.get('build_system', []):
% if not lib.name in ['ares', 'benchmark', 'upb', 'z']: # we build these using CMake instead
% if lib.build in ["test", "private"]:
if (gRPC_BUILD_TESTS)
if(gRPC_BUILD_TESTS)
${cc_library(lib)}
endif (gRPC_BUILD_TESTS)
endif()
% elif lib.name in ['grpc_csharp_ext']:
if (gRPC_BUILD_CSHARP_EXT)
if(gRPC_BUILD_CSHARP_EXT)
${cc_library(lib)}
% if any(proto_re.match(src) for src in lib.src):
if (gRPC_BUILD_CODEGEN)
if(gRPC_BUILD_CODEGEN)
% endif
${cc_install(lib)}
% if any(proto_re.match(src) for src in lib.src):
endif (gRPC_BUILD_CODEGEN)
endif()
% endif
endif (gRPC_BUILD_CSHARP_EXT)
endif()
% else:
${cc_library(lib)}
% if not lib.build in ["tool"]:
% if any(proto_re.match(src) for src in lib.src):
if (gRPC_BUILD_CODEGEN)
if(gRPC_BUILD_CODEGEN)
% endif
${cc_install(lib)}
% if any(proto_re.match(src) for src in lib.src):
endif (gRPC_BUILD_CODEGEN)
endif()
% endif
% endif
% endif
@ -383,32 +412,32 @@
% for tgt in targets:
% if tgt.build in ["all", "protoc", "tool", "test", "private"] and not tgt.boringssl:
% if tgt.build in ["test", "private"]:
if (gRPC_BUILD_TESTS)
${get_platforms_condition_begin(tgt.platforms)}\
if(gRPC_BUILD_TESTS)
<%block filter='platforms_condition_block(tgt.platforms)'>
${cc_binary(tgt)}
${get_platforms_condition_end(tgt.platforms)}\
endif (gRPC_BUILD_TESTS)
</%block>
endif()
% elif tgt.build in ["protoc"]:
if (gRPC_BUILD_CODEGEN)
${get_platforms_condition_begin(tgt.platforms)}\
if(gRPC_BUILD_CODEGEN)
<%block filter='platforms_condition_block(tgt.platforms)'>
${cc_binary(tgt)}
${cc_install(tgt)}
${get_platforms_condition_end(tgt.platforms)}\
endif (gRPC_BUILD_CODEGEN)
</%block>
endif()
% else:
${get_platforms_condition_begin(tgt.platforms)}\
<%block filter='platforms_condition_block(tgt.platforms)'>
${cc_binary(tgt)}
% if not tgt.build in ["tool"]:
${cc_install(tgt)}
% endif
${get_platforms_condition_end(tgt.platforms)}\
</%block>
% endif
% endif
% endfor
<%def name="cc_library(lib)">
% if any(proto_re.match(src) for src in lib.src):
if (gRPC_BUILD_CODEGEN)
if(gRPC_BUILD_CODEGEN)
% endif
add_library(${lib.name}${' SHARED' if lib.get('dll', None) == 'only' else ''}
% for src in lib.src:
@ -443,7 +472,7 @@
set_target_properties(${lib.name} PROPERTIES COMPILE_PDB_NAME "${lib.name}"
COMPILE_PDB_OUTPUT_DIRECTORY <%text>"${CMAKE_BINARY_DIR}</%text>"
)
if (gRPC_INSTALL)
if(gRPC_INSTALL)
install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>${lib.name}.pdb
DESTINATION <%text>${gRPC_INSTALL_LIBDIR}</%text> OPTIONAL
)
@ -452,25 +481,26 @@
target_include_directories(${lib.name}
PUBLIC <%text>$<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include></%text>
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_GENERATED_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_GRPC_GENERATED_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
PRIVATE
<%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
<%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text>
<%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
<%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
<%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
<%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
<%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
<%text>${_gRPC_UPB_GENERATED_DIR}</%text>
<%text>${_gRPC_UPB_GRPC_GENERATED_DIR}</%text>
<%text>${_gRPC_UPB_INCLUDE_DIR}</%text>
<%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
% if lib.build in ['test', 'private'] and lib.language == 'c++':
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
% endif
% if lib.language == 'c++':
PRIVATE <%text>${_gRPC_PROTO_GENS_DIR}</%text>
<%text>${_gRPC_PROTO_GENS_DIR}</%text>
% endif
)
% if len(get_deps(lib)) > 0:
@ -481,17 +511,17 @@
)
% endif
% if lib.name in ["gpr"]:
if (_gRPC_PLATFORM_ANDROID)
if(_gRPC_PLATFORM_ANDROID)
target_link_libraries(gpr
android
log
)
endif (_gRPC_PLATFORM_ANDROID)
endif()
% endif
% if lib.name in ["grpc", "grpc_cronet", "grpc_test_util", \
"grpc_test_util_unsecure", "grpc_unsecure", \
"grpc++_cronet"]:
if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC)
if(_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC)
target_link_libraries(${lib.name} "-framework CoreFoundation")
endif()
%endif
@ -510,7 +540,7 @@
endforeach()
% endif
% if any(proto_re.match(src) for src in lib.src):
endif (gRPC_BUILD_CODEGEN)
endif()
% endif
</%def>
@ -533,26 +563,27 @@
)
target_include_directories(${tgt.name}
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/include
PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_GENERATED_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_GRPC_GENERATED_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
PRIVATE
<%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
<%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/include
<%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text>
<%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
<%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
<%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
<%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
<%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
<%text>${_gRPC_UPB_GENERATED_DIR}</%text>
<%text>${_gRPC_UPB_GRPC_GENERATED_DIR}</%text>
<%text>${_gRPC_UPB_INCLUDE_DIR}</%text>
<%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
% if tgt.build in ['test', 'private'] and tgt.language == 'c++':
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
% endif
% if tgt.language == 'c++':
PRIVATE <%text>${_gRPC_PROTO_GENS_DIR}</%text>
<%text>${_gRPC_PROTO_GENS_DIR}</%text>
% endif
)
@ -567,7 +598,7 @@
</%def>
<%def name="cc_install(tgt)">
if (gRPC_INSTALL)
if(gRPC_INSTALL)
install(TARGETS ${tgt.name} EXPORT gRPCTargets
RUNTIME DESTINATION <%text>${gRPC_INSTALL_BINDIR}</%text>
LIBRARY DESTINATION <%text>${gRPC_INSTALL_LIBDIR}</%text>
@ -576,21 +607,26 @@
endif()
</%def>
if (gRPC_INSTALL)
if(gRPC_INSTALL)
install(EXPORT gRPCTargets
DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text>
NAMESPACE gRPC::
)
endif()
foreach(_config gRPCConfig gRPCConfigVersion)
configure_file(cmake/<%text>${_config}</%text>.cmake.in
<%text>${_config}</%text>.cmake @ONLY)
install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/${_config}</%text>.cmake
DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text>
)
endforeach()
include(CMakePackageConfigHelpers)
configure_file(cmake/gRPCConfig.cmake.in
gRPCConfig.cmake @ONLY)
write_basic_package_version_file(<%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>gRPCConfigVersion.cmake
VERSION <%text>${PACKAGE_VERSION}</%text>
COMPATIBILITY AnyNewerVersion)
install(FILES
<%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>gRPCConfig.cmake
<%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>gRPCConfigVersion.cmake
DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text>
)
install(FILES <%text>${CMAKE_CURRENT_SOURCE_DIR}/etc/roots.pem</%text>
DESTINATION <%text>${gRPC_INSTALL_SHAREDIR}</%text>)

@ -114,8 +114,17 @@ struct read_and_write_test_state {
grpc_slice_buffer outgoing;
grpc_closure done_read;
grpc_closure done_write;
grpc_closure read_scheduler;
grpc_closure write_scheduler;
};
static void read_scheduler(void* data, grpc_error* /* error */) {
struct read_and_write_test_state* state =
static_cast<struct read_and_write_test_state*>(data);
grpc_endpoint_read(state->read_ep, &state->incoming, &state->done_read,
/*urgent=*/false);
}
static void read_and_write_test_read_handler(void* data, grpc_error* error) {
struct read_and_write_test_state* state =
static_cast<struct read_and_write_test_state*>(data);
@ -129,11 +138,21 @@ static void read_and_write_test_read_handler(void* data, grpc_error* error) {
GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr));
gpr_mu_unlock(g_mu);
} else if (error == GRPC_ERROR_NONE) {
grpc_endpoint_read(state->read_ep, &state->incoming, &state->done_read,
/*urgent=*/false);
/* We perform many reads one after another. If grpc_endpoint_read and the
* read_handler are both run inline, we might end up growing the stack
* beyond the limit. Schedule the read on ExecCtx to avoid this. */
grpc_core::ExecCtx::Run(DEBUG_LOCATION, &state->read_scheduler,
GRPC_ERROR_NONE);
}
}
static void write_scheduler(void* data, grpc_error* /* error */) {
struct read_and_write_test_state* state =
static_cast<struct read_and_write_test_state*>(data);
grpc_endpoint_write(state->write_ep, &state->outgoing, &state->done_write,
nullptr);
}
static void read_and_write_test_write_handler(void* data, grpc_error* error) {
struct read_and_write_test_state* state =
static_cast<struct read_and_write_test_state*>(data);
@ -151,8 +170,11 @@ static void read_and_write_test_write_handler(void* data, grpc_error* error) {
&state->current_write_data);
grpc_slice_buffer_reset_and_unref(&state->outgoing);
grpc_slice_buffer_addn(&state->outgoing, slices, nslices);
grpc_endpoint_write(state->write_ep, &state->outgoing, &state->done_write,
nullptr);
/* We perform many writes one after another. If grpc_endpoint_write and
* the write_handler are both run inline, we might end up growing the
* stack beyond the limit. Schedule the write on ExecCtx to avoid this. */
grpc_core::ExecCtx::Run(DEBUG_LOCATION, &state->write_scheduler,
GRPC_ERROR_NONE);
gpr_free(slices);
return;
}
@ -202,8 +224,12 @@ static void read_and_write_test(grpc_endpoint_test_config config,
state.write_done = 0;
state.current_read_data = 0;
state.current_write_data = 0;
GRPC_CLOSURE_INIT(&state.read_scheduler, read_scheduler, &state,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&state.done_read, read_and_write_test_read_handler, &state,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&state.write_scheduler, write_scheduler, &state,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&state.done_write, read_and_write_test_write_handler,
&state, grpc_schedule_on_exec_ctx);
grpc_slice_buffer_init(&state.outgoing);

@ -191,9 +191,9 @@ static void read_cb(void* user_data, grpc_error* error) {
GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
} else {
gpr_mu_unlock(g_mu);
grpc_endpoint_read(state->ep, &state->incoming, &state->read_cb,
/*urgent=*/false);
gpr_mu_unlock(g_mu);
}
}

@ -29,44 +29,55 @@ powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [Sys
@rem set absolute path to OpenSSL with forward slashes
set OPENSSL_DIR=%cd:\=/%/OpenSSL-Win32
cd third_party/zlib
mkdir cmake
cd cmake
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..
@rem Install c-ares
mkdir third_party\cares\cares\cmake\build
pushd third_party\cares\cares\cmake\build
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\..
cmake --build . --config Release --target install || goto :error
cd ../../..
popd
cd third_party/protobuf/cmake
mkdir build
cd build
@rem Install protobuf
mkdir third_party\protobuf\cmake\build
pushd third_party\protobuf\cmake\build
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DZLIB_ROOT=%INSTALL_DIR% -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF ..
cmake --build . --config Release --target install || goto :error
cd ../../../..
popd
cd third_party/cares/cares
mkdir cmake
cd cmake
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..
@rem Install zlib
mkdir third_party\zlib\cmake\build
pushd third_party\zlib\cmake\build
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\..
cmake --build . --config Release --target install || goto :error
cd ../../../..
popd
@rem OpenSSL-Win32 and OpenSSL-Win64 can be downloaded from https://slproweb.com/products/Win32OpenSSL.html
cd cmake
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DZLIB_ROOT=%INSTALL_DIR% -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DCMAKE_BUILD_TYPE=Release ../.. || goto :error
@rem Just before installing gRPC, wipe out contents of all the submodules to simulate
@rem a standalone build from an archive
git submodule deinit --all --force
@rem Install gRPC
mkdir cmake\build
pushd cmake\build
cmake ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^
-DOPENSSL_ROOT_DIR=%OPENSSL_DIR% ^
-DZLIB_ROOT=%INSTALL_DIR% ^
-DgRPC_INSTALL=ON ^
-DgRPC_BUILD_TESTS=OFF ^
-DgRPC_CARES_PROVIDER=package ^
-DgRPC_PROTOBUF_PROVIDER=package ^
-DgRPC_SSL_PROVIDER=package ^
-DgRPC_ZLIB_PROVIDER=package ^
../.. || goto :error
cmake --build . --config Release --target install || goto :error
cd ../..
popd
@rem Build helloworld example using cmake
cd examples/cpp/helloworld
mkdir cmake
cd cmake
mkdir build
cd build
mkdir examples\cpp\helloworld\cmake\build
pushd examples\cpp\helloworld\cmake\build
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DZLIB_ROOT=%INSTALL_DIR% ../.. || goto :error
cmake --build . --config Release || goto :error
cd ../../../../..
popd
goto :EOF

@ -24,33 +24,25 @@ apt-get update
apt-get install -t jessie-backports -y libssl-dev
# Install c-ares
cd third_party/cares/cares
git fetch origin
git checkout cares-1_15_0
mkdir -p cmake/build
cd cmake/build
mkdir -p "third_party/cares/cares/cmake/build"
pushd "third_party/cares/cares/cmake/build"
cmake -DCMAKE_BUILD_TYPE=Release ../..
make -j4 install
cd ../../../../..
rm -rf third_party/cares/cares # wipe out to prevent influencing the grpc build
# Install zlib
cd third_party/zlib
mkdir -p cmake/build
cd cmake/build
cmake -DCMAKE_BUILD_TYPE=Release ../..
make -j4 install
cd ../../../..
rm -rf third_party/zlib # wipe out to prevent influencing the grpc build
popd
# Install protobuf
cd third_party/protobuf
mkdir -p cmake/build
cd cmake/build
mkdir -p "third_party/protobuf/cmake/build"
pushd "third_party/protobuf/cmake/build"
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ..
make -j4 install
cd ../../../..
rm -rf third_party/protobuf # wipe out to prevent influencing the grpc build
popd
# Install zlib
mkdir -p "third_party/zlib/cmake/build"
pushd "third_party/zlib/cmake/build"
cmake -DCMAKE_BUILD_TYPE=Release ../..
make -j4 install
popd
# Just before installing gRPC, wipe out contents of all the submodules to simulate
# a standalone build from an archive
@ -58,15 +50,23 @@ rm -rf third_party/protobuf # wipe out to prevent influencing the grpc build
git submodule foreach 'cd $toplevel; rm -rf $name'
# Install gRPC
mkdir -p cmake/build
cd cmake/build
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DCMAKE_BUILD_TYPE=Release ../..
mkdir -p "cmake/build"
pushd "cmake/build"
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DgRPC_CARES_PROVIDER=package \
-DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_SSL_PROVIDER=package \
-DgRPC_ZLIB_PROVIDER=package \
../..
make -j4 install
cd ../..
popd
# Build helloworld example using cmake
cd examples/cpp/helloworld
mkdir -p cmake/build
cd cmake/build
mkdir -p "examples/cpp/helloworld/cmake/build"
pushd "examples/cpp/helloworld/cmake/build"
cmake ../..
make
popd

@ -24,33 +24,25 @@ apt-get update
apt-get install -t jessie-backports -y libssl-dev pkg-config
# Install c-ares
cd third_party/cares/cares
git fetch origin
git checkout cares-1_15_0
mkdir -p cmake/build
cd cmake/build
mkdir -p "third_party/cares/cares/cmake/build"
pushd "third_party/cares/cares/cmake/build"
cmake -DCMAKE_BUILD_TYPE=Release ../..
make -j4 install
cd ../../../../..
rm -rf third_party/cares/cares # wipe out to prevent influencing the grpc build
# Install zlib
cd third_party/zlib
mkdir -p cmake/build
cd cmake/build
cmake -DCMAKE_BUILD_TYPE=Release ../..
make -j4 install
cd ../../../..
rm -rf third_party/zlib # wipe out to prevent influencing the grpc build
popd
# Install protobuf
cd third_party/protobuf
mkdir -p cmake/build
cd cmake/build
mkdir -p "third_party/protobuf/cmake/build"
pushd "third_party/protobuf/cmake/build"
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ..
make -j4 install
cd ../../../..
rm -rf third_party/protobuf # wipe out to prevent influencing the grpc build
popd
# Install zlib
mkdir -p "third_party/zlib/cmake/build"
pushd "third_party/zlib/cmake/build"
cmake -DCMAKE_BUILD_TYPE=Release ../..
make -j4 install
popd
# Just before installing gRPC, wipe out contents of all the submodules to simulate
# a standalone build from an archive
@ -58,11 +50,20 @@ rm -rf third_party/protobuf # wipe out to prevent influencing the grpc build
git submodule foreach 'cd $toplevel; rm -rf $name'
# Install gRPC
mkdir -p cmake/build
cd cmake/build
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/grpc ../..
mkdir -p "cmake/build"
pushd "cmake/build"
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/grpc \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DgRPC_CARES_PROVIDER=package \
-DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_SSL_PROVIDER=package \
-DgRPC_ZLIB_PROVIDER=package \
../..
make -j4 install
cd ../..
popd
# Build helloworld example using Makefiles and pkg-config
cd examples/cpp/helloworld

@ -1 +1 @@
Subproject commit 74d91756c11bc22f9b0108b94da9326f7f9e376f
Subproject commit 846e5dbedac123d12455adcfe6f53c8b5dcbfeef

@ -15,7 +15,7 @@
# limitations under the License.
licenses(["notice"])
native.objc_library(
objc_library(
name = "GTM_GoogleTestRunner_GTM_USING_XCTEST",
testonly = 1,
srcs = [

@ -260,8 +260,8 @@ def _create_single_version_package(repository_ctx,
# See https://docs.python.org/3/extending/windows.html
if _is_windows(repository_ctx):
python_include = _normalize_path(python_include)
python_import_lib_name = _get_python_import_lib_name, bin_path_key(
repository_ctx, python_bin)
python_import_lib_name = _get_python_import_lib_name(
repository_ctx, python_bin, bin_path_key)
python_import_lib_src = python_include.rsplit(
'/', 1)[0] + "/libs/" + python_import_lib_name
python_import_lib_genrule = _symlink_genrule_for_dir(

@ -18,22 +18,14 @@ set -ex
# change to grpc repo root
cd $(dirname $0)/../../..
# Download bazel
temp_dir="$(mktemp -d)"
wget -q https://github.com/bazelbuild/bazel/releases/download/0.26.0/bazel-0.26.0-darwin-x86_64 -O "${temp_dir}/bazel"
chmod 755 "${temp_dir}/bazel"
export PATH="${temp_dir}:${PATH}"
# This should show ${temp_dir}/bazel
which bazel
./tools/run_tests/start_port_server.py
dirs=(end2end server client common codegen util grpclb test)
for dir in ${dirs[*]}; do
echo $dir
out=`bazel query "kind(ios_unit_test, tests(//test/cpp/$dir/...))"`
out=`tools/bazel query "kind(ios_unit_test, tests(//test/cpp/$dir/...))" 2>/dev/null | grep '^//'`
for test in $out; do
echo "Running: $test"
bazel test --test_summary=detailed --test_output=all $test
tools/bazel test --test_summary=detailed --test_output=all $test
done
done

@ -166,7 +166,7 @@ pip_install_dir() {
}
case "$VENV" in
*py35_gevent*)
*py36_gevent*)
# TODO(https://github.com/grpc/grpc/issues/15411) unpin this
$VENV_PYTHON -m pip install gevent==1.3.b1
;;

@ -872,7 +872,7 @@ class PythonLanguage(object):
if args.compiler == 'default':
if os.name == 'nt':
return (python35_config,)
return (python36_config,)
else:
if args.iomgr_platform == 'asyncio':
return (python36_config,)
@ -907,7 +907,7 @@ class PythonLanguage(object):
python35_config,
python36_config,
python37_config,
# TODO: Add Python 3.8 once it's released.
python38_config,
)
else:
raise Exception('Compiler %s not supported.' % args.compiler)

@ -26,7 +26,7 @@ want_submodules=$(mktemp /tmp/submXXXXXX)
git submodule | awk '{ print $1 }' | sort > "$submodules"
cat << EOF | awk '{ print $1 }' | sort > "$want_submodules"
74d91756c11bc22f9b0108b94da9326f7f9e376f third_party/abseil-cpp (74d9175)
846e5dbedac123d12455adcfe6f53c8b5dcbfeef third_party/abseil-cpp (heads/master)
090faecb454fbd6e6e17a75ef8146acb037118d4 third_party/benchmark (v1.5.0)
73594cde8c9a52a102c4341c244c833aa61b9c06 third_party/bloaty (remotes/origin/wide-14-g73594cd)
7f02881e96e51f1873afcf384d02f782b48967ca third_party/boringssl (remotes/origin/HEAD)

Loading…
Cancel
Save