Print compiler version number in generated files

This commit is contained in:
Lukasz Strzalkowski 2016-04-11 19:34:15 +02:00 committed by Eric Anderson
parent 511bea0568
commit 363e0f6cfc
13 changed files with 28 additions and 12 deletions

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: services.proto") comments = "Source: services.proto")
public class BenchmarkServiceGrpc { public class BenchmarkServiceGrpc {

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: services.proto") comments = "Source: services.proto")
public class WorkerServiceGrpc { public class WorkerServiceGrpc {

View File

@ -75,6 +75,7 @@ model {
binaries { binaries {
all { all {
if (toolChain in Gcc || toolChain in Clang) { if (toolChain in Gcc || toolChain in Clang) {
cppCompiler.define("GRPC_VERSION", version)
cppCompiler.args "--std=c++0x" cppCompiler.args "--std=c++0x"
addEnvArgs("CXXFLAGS", cppCompiler.args) addEnvArgs("CXXFLAGS", cppCompiler.args)
addEnvArgs("CPPFLAGS", cppCompiler.args) addEnvArgs("CPPFLAGS", cppCompiler.args)
@ -95,6 +96,7 @@ model {
} }
addEnvArgs("LDFLAGS", linker.args) addEnvArgs("LDFLAGS", linker.args)
} else if (toolChain in VisualCpp) { } else if (toolChain in VisualCpp) {
cppCompiler.define("GRPC_VERSION", version)
cppCompiler.args "/EHsc", "/MT" cppCompiler.args "/EHsc", "/MT"
if (rootProject.hasProperty('vcProtobufInclude')) { if (rootProject.hasProperty('vcProtobufInclude')) {
cppCompiler.args "/I${rootProject.vcProtobufInclude}" cppCompiler.args "/I${rootProject.vcProtobufInclude}"

View File

@ -9,6 +9,15 @@
#include <google/protobuf/io/printer.h> #include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
// Stringify helpers used solely to cast GRPC_VERSION
#ifndef STR
#define STR(s) #s
#endif
#ifndef XSTR
#define XSTR(s) STR(s)
#endif
namespace java_grpc_generator { namespace java_grpc_generator {
using google::protobuf::FileDescriptor; using google::protobuf::FileDescriptor;
@ -698,10 +707,15 @@ static void PrintService(const ServiceDescriptor* service,
(*vars)["service_name"] = service->name(); (*vars)["service_name"] = service->name();
(*vars)["file_name"] = service->file()->name(); (*vars)["file_name"] = service->file()->name();
(*vars)["service_class_name"] = ServiceClassName(service); (*vars)["service_class_name"] = ServiceClassName(service);
#ifdef GRPC_VERSION
(*vars)["grpc_version"] = " (version " XSTR(GRPC_VERSION) ")";
#else
(*vars)["grpc_version"] = "";
#endif
p->Print( p->Print(
*vars, *vars,
"@$Generated$(\n" "@$Generated$(\n"
" value = \"by gRPC proto compiler\",\n" " value = \"by gRPC proto compiler$grpc_version$\",\n"
" comments = \"Source: $file_name$\")\n" " comments = \"Source: $file_name$\")\n"
"public class $service_class_name$ {\n\n"); "public class $service_class_name$ {\n\n");
p->Indent(); p->Indent();

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: test.proto") comments = "Source: test.proto")
public class TestServiceGrpc { public class TestServiceGrpc {

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: test.proto") comments = "Source: test.proto")
public class TestServiceGrpc { public class TestServiceGrpc {

View File

@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
import java.io.IOException; import java.io.IOException;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: test.proto") comments = "Source: test.proto")
public class TestServiceGrpc { public class TestServiceGrpc {

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: helloworld.proto") comments = "Source: helloworld.proto")
public class GreeterGrpc { public class GreeterGrpc {

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: route_guide.proto") comments = "Source: route_guide.proto")
public class RouteGuideGrpc { public class RouteGuideGrpc {

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: load_balancer.proto") comments = "Source: load_balancer.proto")
public class LoadBalancerGrpc { public class LoadBalancerGrpc {

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: io/grpc/testing/integration/test.proto") comments = "Source: io/grpc/testing/integration/test.proto")
public class ReconnectServiceGrpc { public class ReconnectServiceGrpc {

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: io/grpc/testing/integration/test.proto") comments = "Source: io/grpc/testing/integration/test.proto")
public class TestServiceGrpc { public class TestServiceGrpc {

View File

@ -16,7 +16,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
@javax.annotation.Generated( @javax.annotation.Generated(
value = "by gRPC proto compiler", value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
comments = "Source: io/grpc/testing/integration/test.proto") comments = "Source: io/grpc/testing/integration/test.proto")
public class UnimplementedServiceGrpc { public class UnimplementedServiceGrpc {