Getting the generated Makefile to support .proto files.

-) Compiling the proto plugin using the HOSTCC compiler.
-) Set up proper rules to invoke the plugin from protoc.
-) Few various renaming hacks to fully get out of [].
	Change on 2014/12/12 by nnoble <nnoble@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82000361
pull/1/merge
nnoble 10 years ago committed by Nicolas Noble
parent 3656f94978
commit 72309c6c5d
  1. 124
      Makefile
  2. 33
      build.json
  3. 2
      src/compiler/ruby_generator_string-inl.h
  4. 86
      templates/Makefile.template
  5. 8
      test/cpp/interop/empty.proto
  6. 2
      test/cpp/interop/test.proto

File diff suppressed because one or more lines are too long

@ -343,9 +343,9 @@
"name": "grpc++_test_util",
"build": "test",
"src": [
"test/cpp/end2end/async_test_server.cc",
"test/cpp/util/test_ssl_channel.cc",
"test/cpp/util/echo.proto"
"test/cpp/util/echo.proto",
"test/cpp/end2end/async_test_server.cc"
],
"c++": true
}
@ -1157,11 +1157,16 @@
{
"name": "interop_server",
"build": "test",
"run": false,
"c++": true,
"src": [
"test/cpp/interop/empty.proto",
"test/cpp/interop/messages.proto",
"test/cpp/interop/test.proto",
"test/cpp/interop/server.cc"
],
"deps": [
"grpc++_test_util",
"grpc_test_util",
"grpc++",
"grpc",
@ -1171,11 +1176,16 @@
{
"name": "interop_client",
"build": "test",
"run": false,
"c++": true,
"src": [
"test/cpp/interop/empty.proto",
"test/cpp/interop/messages.proto",
"test/cpp/interop/test.proto",
"test/cpp/interop/client.cc"
],
"deps": [
"grpc++_test_util",
"grpc_test_util",
"grpc++",
"grpc",
@ -1219,25 +1229,6 @@
"grpc",
"gpr"
]
},
{
"name": "interop_client",
"build": "test",
"run": false,
"c++": true,
"src": [
"test/cpp/interop/client.cc",
"test/cpp/interop/empty.pb.cc",
"test/cpp/interop/messages.pb.cc",
"test/cpp/interop/test.pb.cc"
],
"deps": [
"grpc++_test_util",
"grpc_test_util",
"grpc++",
"grpc",
"gpr"
]
}
]
}

@ -112,7 +112,7 @@ inline string RubyTypeOf(const string& a_type, const string& package) {
return res;
} else {
vector<string> prefixes_and_type = Split(res, '.');
for (int i = 0; i < prefixes_and_type.size(); ++i) {
for (unsigned int i = 0; i < prefixes_and_type.size(); ++i) {
if (i != 0) {
res += "::"; // switch '.' to the ruby module delim
}

@ -4,11 +4,19 @@
from copy import deepcopy
import re
proto_re = re.compile('(.*)\.proto')
def excluded(filename, exclude_res):
for r in exclude_res:
if r.match(filename):
return True
return False
def proto_to_cc(filename):
m = proto_re.match(filename)
if not m:
return filename
return 'gens/' + m.group(1) + '.pb.cc'
%>
<%
@ -38,20 +46,19 @@
altlibs.append(new)
libs.extend(altlibs)
protos_dict = {}
proto_re = re.compile('\.proto$')
protos = set()
for lib in libs:
for src in lib.src:
if proto_re.match(src):
protos_dict[src] = True
m = proto_re.match(src)
if m:
protos.add(m.group(1))
for tgt in targets:
for src in tgt.src:
if proto_re.match(src):
protos_dict[src] = True
m = proto_re.match(src)
if m:
protos.add(m.group(1))
protos = []
for k, v in protos_dict:
protos.append(k)
protos = sorted(protos)
%>
# General settings.
@ -69,6 +76,11 @@ STRIP = strip --strip-unneeded
INSTALL = install -D
RM = rm -f
HOST_CC = $(CC)
HOST_CXX = $(CXX)
HOST_LD = $(LD)
HOST_LDXX = $(LDXX)
ifeq ($(DEBUG),)
CPPFLAGS += -O2
DEFINES += NDEBUG
@ -111,7 +123,13 @@ LDFLAGS += $(ARCH_FLAGS)
LDLIBS += $(addprefix -l, $(LIBS))
LDLIBSXX += $(addprefix -l, $(LIBSXX))
LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
HOST_CPPFLAGS = $(CPPFLAGS)
HOST_CFLAGS = $(CFLAGS)
HOST_CXXFLAGS = $(CXXFLAGS)
HOST_LDFLAGS = $(LDFLAGS)
HOST_LDLIBS = $(LDLIBS)
.SECONDARY = %.pb.h %.pb.cc
@ -282,21 +300,23 @@ strip-shared_cxx: shared_cxx
% endif
% endfor
gens/%.pb.cc : %.proto
% for p in protos:
deps/gens/${p}.pb.dep:
$(Q) mkdir -p `dirname $@`
$(Q) touch $@
gens/${p}.pb.cc: ${p}.proto protoc_plugins
$(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) --cpp_out=gens $<
$(Q) $(PROTOC) --cpp_out=gens --grpc_out=gens --plugin=protoc-gen-grpc=bins/cpp_plugin $<
% endfor
deps/%.dep : %.c
$(E) "[DEP] Generating dependencies for $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CC) $(CFLAGS) $(CPPFLAGS_NO_ARCH) -MG -M $< > $@
deps/%.dep : gens/%.pb.cc
$(E) "[DEP] Generating dependencies for $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS_NO_ARCH) -MG -M $< > $@
deps/%.dep : %.cc
$(E) "[DEP] Generating dependencies for $<"
$(Q) mkdir -p `dirname $@`
@ -312,6 +332,11 @@ objs/%.o : gens/%.pb.cc
$(Q) mkdir -p `dirname $@`
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
objs/src/compiler/%.o : src/compiler/%.cc
$(E) "[HOSTCXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -c -o $@ $<
objs/%.o : %.cc
$(E) "[CXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
@ -431,7 +456,7 @@ ${maketarget(tgt)}
LIB${lib.name.upper()}_SRC = \\
% for src in lib.src:
${src} \\
${proto_to_cc(src)} \\
% endfor
@ -491,7 +516,7 @@ clean_lib${lib.name}:
${tgt.name.upper()}_SRC = \\
% for src in tgt.src:
${src} \\
${proto_to_cc(src)} \\
% endfor
@ -503,29 +528,44 @@ bins/${tgt.name}: $(${tgt.name.upper()}_OBJS)\
libs/lib${dep}.a\
% endfor
% if tgt.get("c++", False):
% if tgt.build == 'protoc':
$(E) "[HOSTLD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(HOST_LDXX) $(HOST_LDFLAGS) $(${tgt.name.upper()}_OBJS)\
% else:
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
% if tgt.get("c++", False):
$(Q) $(LDXX) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\
% endif
% if tgt.build == 'test':
$(GTEST_LIB)\
% endif
-Llibs\
% else:
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(${tgt.name.upper()}_OBJS) -Llibs\
% endif
% for dep in tgt.deps:
-l${dep}\
% endfor
% if tgt.get("c++", False):
% if tgt.build == 'protoc':
$(HOST_LDLIBSXX)\
% else:
$(LDLIBSXX)\
% endif
% endif
% if tgt.build == 'protoc':
$(HOST_LDLIBS)\
% else:
$(LDLIBS)\
% if tgt.get('secure', True):
$(LDLIBS_SECURE)\
% endif
% if tgt.build == 'protoc':
$(LDLIBS_PROTOC)\
$(HOST_LDLIBS_PROTOC)\
% elif tgt.get('secure', True):
$(LDLIBS_SECURE)\
% endif
-o bins/${tgt.name}

@ -1,19 +1,19 @@
syntax = "proto2";
package proto2;
package grpc.testing;
// An empty message that you can re-use to avoid defining duplicated empty
// messages in your project. A typical example is to use it as argument or the
// return value of a service API. For instance:
//
// service Foo {
// rpc Bar (proto2.Empty) returns (proto2.Empty) { };
// rpc Bar (grpc.testing.Empty) returns (grpc.testing.Empty) { };
// };
//
// BEGIN GOOGLE-INTERNAL
// MOE:begin_strip
// The difference between this one and net/rpc/empty-message.proto is that
// 1) The generated message here is in proto2 C++ API.
// 2) The proto2.Empty has minimum dependencies
// (no message_set or net/rpc dependencies)
// END GOOGLE-INTERNAL
// MOE:end_strip
message Empty {}

@ -11,7 +11,7 @@ package grpc.testing;
// performance with various types of payload.
service TestService {
// One empty request followed by one empty response.
rpc EmptyCall(proto2.Empty) returns (proto2.Empty);
rpc EmptyCall(grpc.testing.Empty) returns (grpc.testing.Empty);
// One request followed by one response.
// The server returns the client payload as-is.

Loading…
Cancel
Save