Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix_mac_build
Browse files Browse the repository at this point in the history
  • Loading branch information
y-zeng committed Jul 11, 2016
2 parents f0ec5b6 + 20b1d58 commit 9710106
Show file tree
Hide file tree
Showing 54 changed files with 668 additions and 4,568 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ if(NOT ZLIB_ROOT_DIR)
set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
endif()

# 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).
if(NOT protobuf_BUILD_TESTS)
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests")
endif()

add_subdirectory(${BORINGSSL_ROOT_DIR} third_party/boringssl)
add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake third_party/protobuf)
add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib)
Expand Down
1 change: 1 addition & 0 deletions PYTHON-MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ graft include/grpc
graft third_party/boringssl
graft third_party/nanopb
graft third_party/zlib
include src/python/grpcio/build.py
include src/python/grpcio/commands.py
include src/python/grpcio/grpc_version.py
include src/python/grpcio/grpc_core_dependencies.py
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
],
"require": {
"php": ">=5.5.0",
"datto/protobuf-php": "dev-master",
"google/auth": "v0.7"
"datto/protobuf-php": "dev-master"
},
"require-dev": {
"google/auth": "v0.9"
},
"autoload": {
"psr-4": {
Expand Down
29 changes: 23 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import os
import os.path
import platform
import shlex
import shutil
import sys
Expand All @@ -56,10 +57,15 @@
sys.path.insert(0, os.path.abspath(PYTHON_STEM))

# Break import-style to ensure we can actually find our in-repo dependencies.
import _unixccompiler_patch
import commands
import grpc_core_dependencies
import grpc_version

# TODO(atash) make this conditional on being on a mingw32 build
_unixccompiler_patch.monkeypatch_unix_compiler()


LICENSE = '3-clause BSD'

# Environment variable to determine whether or not the Cython extension should
Expand All @@ -72,6 +78,14 @@
ENABLE_CYTHON_TRACING = os.environ.get(
'GRPC_PYTHON_ENABLE_CYTHON_TRACING', False)

# There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are
# entirely ignored/dropped/forgotten by distutils and its Cygwin/MinGW support.
# We use these environment variables to thus get around that without locking
# ourselves in w.r.t. the multitude of operating systems this ought to build on.
# By default we assume a GCC-like compiler.
EXTRA_COMPILE_ARGS = shlex.split(os.environ.get('GRPC_PYTHON_CFLAGS', ''))
EXTRA_LINK_ARGS = shlex.split(os.environ.get('GRPC_PYTHON_LDFLAGS', ''))

CYTHON_EXTENSION_PACKAGE_NAMES = ()

CYTHON_EXTENSION_MODULE_NAMES = ('grpc._cython.cygrpc',)
Expand All @@ -81,9 +95,7 @@
os.path.join(PYTHON_STEM, 'grpc/_cython/imports.generated.c'),
)

CORE_C_FILES = ()
if not "win32" in sys.platform:
CORE_C_FILES += tuple(grpc_core_dependencies.CORE_SOURCE_FILES)
CORE_C_FILES = tuple(grpc_core_dependencies.CORE_SOURCE_FILES)

EXTENSION_INCLUDE_DIRECTORIES = (
(PYTHON_STEM,) + CORE_INCLUDE + BORINGSSL_INCLUDE + ZLIB_INCLUDE)
Expand All @@ -93,12 +105,17 @@
EXTENSION_LIBRARIES += ('rt',)
if not "win32" in sys.platform:
EXTENSION_LIBRARIES += ('m',)
if "win32" in sys.platform:
EXTENSION_LIBRARIES += ('ws2_32',)

DEFINE_MACROS = (('OPENSSL_NO_ASM', 1), ('_WIN32_WINNT', 0x600), ('GPR_BACKWARDS_COMPATIBILITY_MODE', 1),)
if "win32" in sys.platform:
DEFINE_MACROS += (('OPENSSL_WINDOWS', 1), ('WIN32_LEAN_AND_MEAN', 1),)
if '64bit' in platform.architecture()[0]:
DEFINE_MACROS += (('MS_WIN64', 1),)

LDFLAGS = shlex.split(os.environ.get('GRPC_PYTHON_LDFLAGS', ''))
CFLAGS = shlex.split(os.environ.get('GRPC_PYTHON_CFLAGS', ''))

LDFLAGS = tuple(EXTRA_LINK_ARGS)
CFLAGS = tuple(EXTRA_COMPILE_ARGS)
if "linux" in sys.platform:
LDFLAGS += ('-Wl,-wrap,memcpy',)
if "linux" in sys.platform or "darwin" in sys.platform:
Expand Down
23 changes: 21 additions & 2 deletions src/compiler/objective_c_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
#include "src/compiler/objective_c_generator.h"
#include "src/compiler/objective_c_generator_helpers.h"

#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>

using ::google::protobuf::compiler::objectivec::ProtobufLibraryFrameworkName;
using ::google::protobuf::compiler::objectivec::IsProtobufLibraryBundledProtoFile;

class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
public:
ObjectiveCGrpcGenerator() {}
Expand Down Expand Up @@ -72,7 +77,21 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
for (int i = 0; i < file->dependency_count(); i++) {
::grpc::string header = grpc_objective_c_generator::MessageHeaderName(
file->dependency(i));
proto_imports += ::grpc::string("#import \"") + header + "\"\n";
const grpc::protobuf::FileDescriptor *dependency = file->dependency(i);
if (IsProtobufLibraryBundledProtoFile(dependency)) {
::grpc::string base_name = header;
grpc_generator::StripPrefix(&base_name, "google/protobuf/");
// create the import code snippet
proto_imports +=
"#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS\n"
" #import <" + ::grpc::string(ProtobufLibraryFrameworkName) +
"/" + base_name + ">\n"
"#else\n"
" #import \"" + header + "\"\n"
"#endif\n";
} else {
proto_imports += ::grpc::string("#import \"") + header + "\"\n";
}
}

::grpc::string declarations;
Expand All @@ -85,7 +104,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
static const ::grpc::string kNonNullEnd = "\nNS_ASSUME_NONNULL_END\n";

Write(context, file_name + ".pbrpc.h",
imports + '\n' + proto_imports + '\n' + kNonNullBegin +
imports + '\n' + proto_imports + '\n' + kNonNullBegin +
declarations + kNonNullEnd);
}

Expand Down
Loading

0 comments on commit 9710106

Please sign in to comment.