Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: support deprecated proto option #4741

Merged
merged 1 commit into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
TestService.java.txt binary
TestServiceLite.java.txt binary
TestServiceNano.java.txt binary
TestDeprecatedService.java.txt binary
TestDeprecatedServiceLite.java.txt binary
TestDeprecatedServiceNano.java.txt binary
18 changes: 12 additions & 6 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ artifacts {
}
}

def configureTestTask(Task task, String dep, String extraPackage) {
def configureTestTask(Task task, String dep, String extraPackage, String serviceName) {
test.dependsOn task
task.dependsOn "generateTest${dep}Proto"
if (osdetector.os != 'windows') {
Expand All @@ -312,13 +312,19 @@ def configureTestTask(Task task, String dep, String extraPackage) {
}
// File isn't found on Windows if last slash is forward-slash
def slash = System.getProperty("file.separator")
task.args "$buildDir/generated/source/proto/test${dep}/grpc/io/grpc/testing/compiler${extraPackage}${slash}TestServiceGrpc.java",
"$projectDir/src/test${dep}/golden/TestService.java.txt"
task.args "$buildDir/generated/source/proto/test${dep}/grpc/io/grpc/testing/compiler${extraPackage}${slash}${serviceName}Grpc.java",
"$projectDir/src/test${dep}/golden/${serviceName}.java.txt"
}

task testGolden(type: Exec)
task testLiteGolden(type: Exec)
task testNanoGolden(type: Exec)
configureTestTask(testGolden, '', '')
configureTestTask(testLiteGolden, 'Lite', '')
configureTestTask(testNanoGolden, 'Nano', '/nano')
task testDeprecatedGolden(type: Exec)
task testDeprecatedLiteGolden(type: Exec)
task testDeprecatedNanoGolden(type: Exec)
configureTestTask(testGolden, '', '', 'TestService')
configureTestTask(testLiteGolden, 'Lite', '', 'TestService')
configureTestTask(testNanoGolden, 'Nano', '/nano', 'TestService')
configureTestTask(testDeprecatedGolden, '', '', 'TestDeprecatedService')
configureTestTask(testDeprecatedLiteGolden, 'Lite', '', 'TestDeprecatedService')
configureTestTask(testDeprecatedNanoGolden, 'Nano', '/nano', 'TestDeprecatedService')
20 changes: 19 additions & 1 deletion compiler/src/java_plugin/cpp/java_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vector>
#include <google/protobuf/compiler/java/java_names.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>

Expand Down Expand Up @@ -644,6 +645,11 @@ static void PrintStub(
if (!interface) {
GrpcWriteServiceDocComment(p, service);
}

if (service->options().deprecated()) {
p->Print(*vars, "@$Deprecated$\n");
}

if (impl_base) {
p->Print(
*vars,
Expand Down Expand Up @@ -713,6 +719,11 @@ static void PrintStub(
if (!interface) {
GrpcWriteMethodDocComment(p, method);
}

if (method->options().deprecated()) {
p->Print(*vars, "@$Deprecated$\n");
}

p->Print("public ");
switch (call_type) {
case BLOCKING_CALL:
Expand Down Expand Up @@ -1152,7 +1163,14 @@ static void PrintService(const ServiceDescriptor* service,
*vars,
"@$Generated$(\n"
" value = \"by gRPC proto compiler$grpc_version$\",\n"
" comments = \"Source: $file_name$\")\n"
" comments = \"Source: $file_name$\")\n");

if (service->options().deprecated()) {
p->Print(*vars, "@$Deprecated$\n");
}

p->Print(
*vars,
"public final class $service_class_name$ {\n\n");
p->Indent();
p->Print(
Expand Down