Merge github.com:grpc/grpc into tis-but-thy-name

pull/2303/head
Craig Tiller 10 years ago
commit d32d1377c3
  1. 18
      BUILD
  2. 78
      Makefile
  3. 4
      src/objective-c/ProtoRPC/ProtoRPC.m
  4. 6
      src/php/bin/determine_extension_dir.sh
  5. 6
      src/python/src/grpc/_adapter/_c/types.h
  6. 53
      src/python/src/grpc/_adapter/_c/utility.c
  7. 3
      src/python/src/grpc/_adapter/_intermediary_low.py
  8. 3
      src/python/src/grpc/_adapter/_intermediary_low_test.py
  9. 18
      templates/BUILD.template
  10. 78
      templates/Makefile.template

18
BUILD

@ -1319,3 +1319,21 @@ objc_bundle_library(
name = "gRPCCertificates", name = "gRPCCertificates",
resources = ["etc/roots.pem"], resources = ["etc/roots.pem"],
) )
proto_objc_rpc_path = objc_path + "/ProtoRPC"
objc_library(
name = "proto_objc_rpc",
hdrs = glob([
proto_objc_rpc_path + "/*.h",
]),
srcs = glob([
proto_objc_rpc_path + "/*.m",
]),
includes = [objc_path],
deps = [
":grpc_client",
":rx_library",
"//external:protobuf_objc",
],
)

@ -331,6 +331,8 @@ HOST_LDLIBS = $(LDLIBS)
# These are automatically computed variables. # These are automatically computed variables.
# There shouldn't be any need to change anything from now on. # There shouldn't be any need to change anything from now on.
HAS_PKG_CONFIG = $(shell command -v pkg-config >/dev/null 2>&1 && echo true || echo false)
ifeq ($(SYSTEM),MINGW32) ifeq ($(SYSTEM),MINGW32)
SHARED_EXT = dll SHARED_EXT = dll
endif endif
@ -355,6 +357,13 @@ ifeq ($(SYSTEM),Darwin)
OPENSSL_REQUIRES_DL = true OPENSSL_REQUIRES_DL = true
endif endif
ifeq ($(HAS_PKG_CONFIG),true)
OPENSSL_ALPN_CHECK_CMD = pkg-config --atleast-version=1.0.2 openssl
ZLIB_CHECK_CMD = pkg-config --exists zlib
PERFTOOLS_CHECK_CMD = pkg-config --exists profiler
PROTOBUF_CHECK_CMD = pkg-config --atleast-version=3.0.0-alpha-3 protobuf
else # HAS_PKG_CONFIG
ifeq ($(SYSTEM),MINGW32) ifeq ($(SYSTEM),MINGW32)
OPENSSL_LIBS = ssl32 eay32 OPENSSL_LIBS = ssl32 eay32
else else
@ -365,15 +374,18 @@ OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/ope
ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS) ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS) PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS) PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
PROTOC_CHECK_CMD = which protoc > /dev/null
PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
DTRACE_CHECK_CMD = which dtrace > /dev/null
SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
ifeq ($(OPENSSL_REQUIRES_DL),true) ifeq ($(OPENSSL_REQUIRES_DL),true)
OPENSSL_ALPN_CHECK_CMD += -ldl OPENSSL_ALPN_CHECK_CMD += -ldl
endif endif
endif # HAS_PKG_CONFIG
PROTOC_CHECK_CMD = which protoc > /dev/null
PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
DTRACE_CHECK_CMD = which dtrace > /dev/null
SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_PERFTOOLS),true) ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
@ -442,9 +454,33 @@ LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
else else
DEP_MISSING += zlib DEP_MISSING += zlib
endif endif
else
ifeq ($(HAS_PKG_CONFIG),true)
CPPFLAGS += $(shell pkg-config --cflags zlib)
LDFLAGS += $(shell pkg-config --libs-only-L zlib)
endif
endif endif
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false) OPENSSL_PKG_CONFIG = false
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
ifeq ($(HAS_PKG_CONFIG),true)
OPENSSL_PKG_CONFIG = true
CPPFLAGS := $(shell pkg-config --cflags openssl) $(CPPFLAGS)
LDFLAGS_OPENSSL_PKG_CONFIG = $(shell pkg-config --libs-only-L openssl)
ifeq ($(SYSTEM),Linux)
ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
LDFLAGS_OPENSSL_PKG_CONFIG += $(shell pkg-config --libs-only-L openssl | sed s/L/Wl,-rpath,/)
endif
endif
LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
else
LIBS_SECURE = $(OPENSSL_LIBS)
ifeq ($(OPENSSL_REQUIRES_DL),true)
LIBS_SECURE += dl
endif
endif
else
ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true) ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a
OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a
@ -457,16 +493,28 @@ endif
else else
NO_SECURE = true NO_SECURE = true
endif endif
else
LIBS_SECURE = $(OPENSSL_LIBS)
ifeq ($(OPENSSL_REQUIRES_DL),true)
LIBS_SECURE += dl
endif
endif endif
ifeq ($(OPENSSL_PKG_CONFIG),true)
LDLIBS_SECURE += $(shell pkg-config --libs-only-l openssl)
else
LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE)) LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
endif
PROTOBUF_PKG_CONFIG = false
ifeq ($(HAS_SYSTEM_PROTOBUF),false) ifeq ($(HAS_SYSTEM_PROTOBUF),true)
ifeq ($(HAS_PKG_CONFIG),true)
PROTOBUF_PKG_CONFIG = true
CPPFLAGS := $(shell pkg-config --cflags protobuf) $(CPPFLAGS)
LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell pkg-config --libs-only-L protobuf)
ifeq ($(SYSTEM),Linux)
ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell pkg-config --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
endif
endif
endif
else
ifeq ($(HAS_EMBEDDED_PROTOBUF),true) ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS) CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
@ -475,15 +523,19 @@ PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
else else
NO_PROTOBUF = true NO_PROTOBUF = true
endif endif
else
endif endif
LIBS_PROTOBUF = protobuf LIBS_PROTOBUF = protobuf
LIBS_PROTOC = protoc protobuf LIBS_PROTOC = protoc protobuf
LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC)) HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
ifeq ($(PROTOBUF_PKG_CONFIG),true)
LDLIBS_PROTOBUF += $(shell pkg-config --libs-only-l protobuf)
else
LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
endif
ifeq ($(MAKECMDGOALS),clean) ifeq ($(MAKECMDGOALS),clean)
NO_DEPS = true NO_DEPS = true
endif endif

@ -33,7 +33,7 @@
#import "ProtoRPC.h" #import "ProtoRPC.h"
#import <Protobuf/GPBProtocolBuffers.h> #import <GPBProtocolBuffers.h>
#import <RxLibrary/GRXWriteable.h> #import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXWriter.h> #import <RxLibrary/GRXWriter.h>
#import <RxLibrary/GRXWriter+Transformations.h> #import <RxLibrary/GRXWriter+Transformations.h>
@ -66,6 +66,8 @@
// A writer that serializes the proto messages to send. // A writer that serializes the proto messages to send.
id<GRXWriter> bytesWriter = id<GRXWriter> bytesWriter =
[[[GRXWriter alloc] initWithWriter:requestsWriter] map:^id(GPBMessage *proto) { [[[GRXWriter alloc] initWithWriter:requestsWriter] map:^id(GPBMessage *proto) {
// TODO(jcanizales): Fail with an understandable error message if the requestsWriter isn't
// sending GPBMessages.
return [proto data]; return [proto data];
}]; }];
if ((self = [super initWithHost:host method:method requestsWriter:bytesWriter])) { if ((self = [super initWithHost:host method:method requestsWriter:bytesWriter])) {

@ -29,15 +29,15 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -e set -e
default_extension_dir=$(php -i | grep extension_dir | sed 's/.*=> //g') default_extension_dir=$(php-config --extension-dir)
if command -v brew >/dev/null && [ -d $(brew --prefix)/opt/grpc-php ]; then if command -v brew >/dev/null && [ -d $(brew --prefix)/opt/grpc-php ]; then
# homebrew and the grpc-php formula are installed # homebrew and the grpc-php formula are installed
extension_dir="-d extension_dir="$(brew --prefix)/opt/grpc-php extension_dir="-d extension_dir="$(brew --prefix)/opt/grpc-php
elif [ ! -f $default_extension_dir/grpc.so ]; then elif [ ! -e $default_extension_dir/grpc.so ]; then
# the grpc extension is not found in the default PHP extension dir # the grpc extension is not found in the default PHP extension dir
# try the source modules directory # try the source modules directory
module_dir=../ext/grpc/modules module_dir=../ext/grpc/modules
if [ ! -f $module_dir/grpc.so ]; then if [ ! -e $module_dir/grpc.so ]; then
echo "Please run 'phpize && ./configure && make' from ext/grpc first" echo "Please run 'phpize && ./configure && make' from ext/grpc first"
exit 1 exit 1
fi fi

@ -241,10 +241,10 @@ double pygrpc_cast_gpr_timespec_to_double(gpr_timespec timespec);
gpr_timespec pygrpc_cast_double_to_gpr_timespec(double seconds); gpr_timespec pygrpc_cast_double_to_gpr_timespec(double seconds);
/* Returns true on success, false on failure. */ /* Returns true on success, false on failure. */
int pygrpc_cast_pylist_to_send_metadata( int pygrpc_cast_pyseq_to_send_metadata(
PyObject *pylist, grpc_metadata **metadata, size_t *count); PyObject *pyseq, grpc_metadata **metadata, size_t *count);
/* Returns a metadata array as a Python object on success, else NULL. */ /* Returns a metadata array as a Python object on success, else NULL. */
PyObject *pygrpc_cast_metadata_array_to_pylist(grpc_metadata_array metadata); PyObject *pygrpc_cast_metadata_array_to_pyseq(grpc_metadata_array metadata);
/* Transliterate from a list of python channel arguments (2-tuples of string /* Transliterate from a list of python channel arguments (2-tuples of string
and string|integer|None) to a grpc_channel_args object. The strings placed and string|integer|None) to a grpc_channel_args object. The strings placed

@ -32,6 +32,7 @@
*/ */
#include <math.h> #include <math.h>
#include <string.h>
#define PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN
#include <Python.h> #include <Python.h>
@ -118,7 +119,7 @@ PyObject *pygrpc_consume_event(grpc_event event) {
tag->request_call_details.method, tag->request_call_details.host, tag->request_call_details.method, tag->request_call_details.host,
pygrpc_cast_gpr_timespec_to_double(tag->request_call_details.deadline), pygrpc_cast_gpr_timespec_to_double(tag->request_call_details.deadline),
GRPC_OP_RECV_INITIAL_METADATA, GRPC_OP_RECV_INITIAL_METADATA,
pygrpc_cast_metadata_array_to_pylist(tag->request_metadata), Py_None, pygrpc_cast_metadata_array_to_pyseq(tag->request_metadata), Py_None,
Py_None, Py_None, Py_None, Py_None, Py_None, Py_None,
event.success ? Py_True : Py_False); event.success ? Py_True : Py_False);
} else { } else {
@ -172,7 +173,7 @@ int pygrpc_produce_op(PyObject *op, grpc_op *result) {
c_op.flags = 0; c_op.flags = 0;
switch (type) { switch (type) {
case GRPC_OP_SEND_INITIAL_METADATA: case GRPC_OP_SEND_INITIAL_METADATA:
if (!pygrpc_cast_pylist_to_send_metadata( if (!pygrpc_cast_pyseq_to_send_metadata(
PyTuple_GetItem(op, INITIAL_METADATA_INDEX), PyTuple_GetItem(op, INITIAL_METADATA_INDEX),
&c_op.data.send_initial_metadata.metadata, &c_op.data.send_initial_metadata.metadata,
&c_op.data.send_initial_metadata.count)) { &c_op.data.send_initial_metadata.count)) {
@ -190,7 +191,7 @@ int pygrpc_produce_op(PyObject *op, grpc_op *result) {
/* Don't need to fill in any other fields. */ /* Don't need to fill in any other fields. */
break; break;
case GRPC_OP_SEND_STATUS_FROM_SERVER: case GRPC_OP_SEND_STATUS_FROM_SERVER:
if (!pygrpc_cast_pylist_to_send_metadata( if (!pygrpc_cast_pyseq_to_send_metadata(
PyTuple_GetItem(op, TRAILING_METADATA_INDEX), PyTuple_GetItem(op, TRAILING_METADATA_INDEX),
&c_op.data.send_status_from_server.trailing_metadata, &c_op.data.send_status_from_server.trailing_metadata,
&c_op.data.send_status_from_server.trailing_metadata_count)) { &c_op.data.send_status_from_server.trailing_metadata_count)) {
@ -247,8 +248,16 @@ int pygrpc_produce_op(PyObject *op, grpc_op *result) {
} }
void pygrpc_discard_op(grpc_op op) { void pygrpc_discard_op(grpc_op op) {
size_t i;
switch(op.op) { switch(op.op) {
case GRPC_OP_SEND_INITIAL_METADATA: case GRPC_OP_SEND_INITIAL_METADATA:
/* Whenever we produce send-metadata, we allocate new strings (to handle
arbitrary sequence input as opposed to just lists or just tuples). We
thus must free those elements. */
for (i = 0; i < op.data.send_initial_metadata.count; ++i) {
gpr_free((void *)op.data.send_initial_metadata.metadata[i].key);
gpr_free((void *)op.data.send_initial_metadata.metadata[i].value);
}
gpr_free(op.data.send_initial_metadata.metadata); gpr_free(op.data.send_initial_metadata.metadata);
break; break;
case GRPC_OP_SEND_MESSAGE: case GRPC_OP_SEND_MESSAGE:
@ -258,6 +267,16 @@ void pygrpc_discard_op(grpc_op op) {
/* Don't need to free any fields. */ /* Don't need to free any fields. */
break; break;
case GRPC_OP_SEND_STATUS_FROM_SERVER: case GRPC_OP_SEND_STATUS_FROM_SERVER:
/* Whenever we produce send-metadata, we allocate new strings (to handle
arbitrary sequence input as opposed to just lists or just tuples). We
thus must free those elements. */
for (i = 0; i < op.data.send_status_from_server.trailing_metadata_count;
++i) {
gpr_free(
(void *)op.data.send_status_from_server.trailing_metadata[i].key);
gpr_free(
(void *)op.data.send_status_from_server.trailing_metadata[i].value);
}
gpr_free(op.data.send_status_from_server.trailing_metadata); gpr_free(op.data.send_status_from_server.trailing_metadata);
gpr_free((char *)op.data.send_status_from_server.status_details); gpr_free((char *)op.data.send_status_from_server.status_details);
break; break;
@ -419,31 +438,41 @@ void pygrpc_discard_channel_args(grpc_channel_args args) {
gpr_free(args.args); gpr_free(args.args);
} }
int pygrpc_cast_pylist_to_send_metadata( int pygrpc_cast_pyseq_to_send_metadata(
PyObject *pylist, grpc_metadata **metadata, size_t *count) { PyObject *pyseq, grpc_metadata **metadata, size_t *count) {
size_t i; size_t i;
Py_ssize_t value_length; Py_ssize_t value_length;
*count = PyList_Size(pylist); char *key;
char *value;
if (!PySequence_Check(pyseq)) {
return 0;
}
*count = PySequence_Size(pyseq);
*metadata = gpr_malloc(sizeof(grpc_metadata) * *count); *metadata = gpr_malloc(sizeof(grpc_metadata) * *count);
for (i = 0; i < *count; ++i) { for (i = 0; i < *count; ++i) {
if (!PyArg_ParseTuple( PyObject *item = PySequence_GetItem(pyseq, i);
PyList_GetItem(pylist, i), "ss#", if (!PyArg_ParseTuple(item, "ss#", &key, &value, &value_length)) {
&(*metadata)[i].key, &(*metadata)[i].value, &value_length)) { Py_DECREF(item);
gpr_free(*metadata); gpr_free(*metadata);
*count = 0; *count = 0;
*metadata = NULL; *metadata = NULL;
return 0; return 0;
} else {
(*metadata)[i].key = gpr_strdup(key);
(*metadata)[i].value = gpr_malloc(value_length);
memcpy((void *)(*metadata)[i].value, value, value_length);
Py_DECREF(item);
} }
(*metadata)[i].value_length = value_length; (*metadata)[i].value_length = value_length;
} }
return 1; return 1;
} }
PyObject *pygrpc_cast_metadata_array_to_pylist(grpc_metadata_array metadata) { PyObject *pygrpc_cast_metadata_array_to_pyseq(grpc_metadata_array metadata) {
PyObject *result = PyList_New(metadata.count); PyObject *result = PyTuple_New(metadata.count);
size_t i; size_t i;
for (i = 0; i < metadata.count; ++i) { for (i = 0; i < metadata.count; ++i) {
PyList_SetItem( PyTuple_SetItem(
result, i, Py_BuildValue( result, i, Py_BuildValue(
"ss#", metadata.metadata[i].key, metadata.metadata[i].value, "ss#", metadata.metadata[i].key, metadata.metadata[i].value,
(Py_ssize_t)metadata.metadata[i].value_length)); (Py_ssize_t)metadata.metadata[i].value_length));

@ -144,10 +144,11 @@ class Call(object):
self._metadata.append((key, value)) self._metadata.append((key, value))
def premetadata(self): def premetadata(self):
return self._internal.start_batch([ result = self._internal.start_batch([
_types.OpArgs.send_initial_metadata(self._metadata) _types.OpArgs.send_initial_metadata(self._metadata)
], _IGNORE_ME_TAG) ], _IGNORE_ME_TAG)
self._metadata = [] self._metadata = []
return result
def read(self, tag): def read(self, tag):
return self._internal.start_batch([ return self._internal.start_batch([

@ -282,6 +282,9 @@ class EchoTest(unittest.TestCase):
self.assertIn(server_trailing_binary_metadata_key, metadata) self.assertIn(server_trailing_binary_metadata_key, metadata)
self.assertEqual(server_trailing_binary_metadata_value, self.assertEqual(server_trailing_binary_metadata_value,
metadata[server_trailing_binary_metadata_key]) metadata[server_trailing_binary_metadata_key])
self.assertSetEqual(set(key for key, _ in finish_accepted.metadata),
set((server_trailing_metadata_key,
server_trailing_binary_metadata_key,)))
server_timeout_none_event = self.server_completion_queue.get(0) server_timeout_none_event = self.server_completion_queue.get(0)
self.assertIsNone(server_timeout_none_event) self.assertIsNone(server_timeout_none_event)

@ -205,3 +205,21 @@ objc_bundle_library(
name = "gRPCCertificates", name = "gRPCCertificates",
resources = ["etc/roots.pem"], resources = ["etc/roots.pem"],
) )
proto_objc_rpc_path = objc_path + "/ProtoRPC"
objc_library(
name = "proto_objc_rpc",
hdrs = glob([
proto_objc_rpc_path + "/*.h",
]),
srcs = glob([
proto_objc_rpc_path + "/*.m",
]),
includes = [objc_path],
deps = [
":grpc_client",
":rx_library",
"//external:protobuf_objc",
],
)

@ -345,6 +345,8 @@ HOST_LDLIBS = $(LDLIBS)
# These are automatically computed variables. # These are automatically computed variables.
# There shouldn't be any need to change anything from now on. # There shouldn't be any need to change anything from now on.
HAS_PKG_CONFIG = $(shell command -v pkg-config >/dev/null 2>&1 && echo true || echo false)
ifeq ($(SYSTEM),MINGW32) ifeq ($(SYSTEM),MINGW32)
SHARED_EXT = dll SHARED_EXT = dll
endif endif
@ -369,6 +371,13 @@ ifeq ($(SYSTEM),Darwin)
OPENSSL_REQUIRES_DL = true OPENSSL_REQUIRES_DL = true
endif endif
ifeq ($(HAS_PKG_CONFIG),true)
OPENSSL_ALPN_CHECK_CMD = pkg-config --atleast-version=1.0.2 openssl
ZLIB_CHECK_CMD = pkg-config --exists zlib
PERFTOOLS_CHECK_CMD = pkg-config --exists profiler
PROTOBUF_CHECK_CMD = pkg-config --atleast-version=3.0.0-alpha-3 protobuf
else # HAS_PKG_CONFIG
ifeq ($(SYSTEM),MINGW32) ifeq ($(SYSTEM),MINGW32)
OPENSSL_LIBS = ssl32 eay32 OPENSSL_LIBS = ssl32 eay32
else else
@ -379,15 +388,18 @@ OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/ope
ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS) ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS) PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS) PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
PROTOC_CHECK_CMD = which protoc > /dev/null
PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
DTRACE_CHECK_CMD = which dtrace > /dev/null
SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
ifeq ($(OPENSSL_REQUIRES_DL),true) ifeq ($(OPENSSL_REQUIRES_DL),true)
OPENSSL_ALPN_CHECK_CMD += -ldl OPENSSL_ALPN_CHECK_CMD += -ldl
endif endif
endif # HAS_PKG_CONFIG
PROTOC_CHECK_CMD = which protoc > /dev/null
PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
DTRACE_CHECK_CMD = which dtrace > /dev/null
SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_PERFTOOLS),true) ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
@ -456,9 +468,33 @@ LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
else else
DEP_MISSING += zlib DEP_MISSING += zlib
endif endif
else
ifeq ($(HAS_PKG_CONFIG),true)
CPPFLAGS += $(shell pkg-config --cflags zlib)
LDFLAGS += $(shell pkg-config --libs-only-L zlib)
endif
endif endif
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false) OPENSSL_PKG_CONFIG = false
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
ifeq ($(HAS_PKG_CONFIG),true)
OPENSSL_PKG_CONFIG = true
CPPFLAGS := $(shell pkg-config --cflags openssl) $(CPPFLAGS)
LDFLAGS_OPENSSL_PKG_CONFIG = $(shell pkg-config --libs-only-L openssl)
ifeq ($(SYSTEM),Linux)
ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
LDFLAGS_OPENSSL_PKG_CONFIG += $(shell pkg-config --libs-only-L openssl | sed s/L/Wl,-rpath,/)
endif
endif
LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
else
LIBS_SECURE = $(OPENSSL_LIBS)
ifeq ($(OPENSSL_REQUIRES_DL),true)
LIBS_SECURE += dl
endif
endif
else
ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true) ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a
OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a
@ -471,16 +507,28 @@ endif
else else
NO_SECURE = true NO_SECURE = true
endif endif
else
LIBS_SECURE = $(OPENSSL_LIBS)
ifeq ($(OPENSSL_REQUIRES_DL),true)
LIBS_SECURE += dl
endif
endif endif
ifeq ($(OPENSSL_PKG_CONFIG),true)
LDLIBS_SECURE += $(shell pkg-config --libs-only-l openssl)
else
LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE)) LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
endif
PROTOBUF_PKG_CONFIG = false
ifeq ($(HAS_SYSTEM_PROTOBUF),false) ifeq ($(HAS_SYSTEM_PROTOBUF),true)
ifeq ($(HAS_PKG_CONFIG),true)
PROTOBUF_PKG_CONFIG = true
CPPFLAGS := $(shell pkg-config --cflags protobuf) $(CPPFLAGS)
LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell pkg-config --libs-only-L protobuf)
ifeq ($(SYSTEM),Linux)
ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell pkg-config --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
endif
endif
endif
else
ifeq ($(HAS_EMBEDDED_PROTOBUF),true) ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS) CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
@ -489,15 +537,19 @@ PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
else else
NO_PROTOBUF = true NO_PROTOBUF = true
endif endif
else
endif endif
LIBS_PROTOBUF = protobuf LIBS_PROTOBUF = protobuf
LIBS_PROTOC = protoc protobuf LIBS_PROTOC = protoc protobuf
LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC)) HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
ifeq ($(PROTOBUF_PKG_CONFIG),true)
LDLIBS_PROTOBUF += $(shell pkg-config --libs-only-l protobuf)
else
LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
endif
ifeq ($(MAKECMDGOALS),clean) ifeq ($(MAKECMDGOALS),clean)
NO_DEPS = true NO_DEPS = true
endif endif

Loading…
Cancel
Save