aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler/ruby_plugin.cc
diff options
context:
space:
mode:
authorGravatar temiola <temiola@google.com>2015-01-07 11:43:05 -0800
committerGravatar Tim Emiola <temiola@google.com>2015-01-08 12:44:01 -0800
commite5206aace91f9d833cd3a5cc0ef38accc2d78425 (patch)
tree1c2751fe603477f61590a3997a42665d744ef7a4 /src/compiler/ruby_plugin.cc
parent03df7f653a15468ff11ed77206e443e81cc1d4d4 (diff)
Updates the ruby generator so that it does not create files for empty protos.
Previously, this alway generated a service file with a header. However, this does not work well, it means whenver the ruby service plugin is used, every proto file ends up with a service file. Change on 2015/01/07 by temiola <temiola@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=83448951
Diffstat (limited to 'src/compiler/ruby_plugin.cc')
-rw-r--r--src/compiler/ruby_plugin.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/compiler/ruby_plugin.cc b/src/compiler/ruby_plugin.cc
index 62229f9217..c1748cfaeb 100644
--- a/src/compiler/ruby_plugin.cc
+++ b/src/compiler/ruby_plugin.cc
@@ -55,16 +55,19 @@ class RubyGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
const string& parameter,
google::protobuf::compiler::GeneratorContext* context,
string* error) const override {
+ string code = grpc_ruby_generator::GetServices(file);
+ if (code.size() == 0) {
+ return true; // don't generate a file if there are no services
+ }
+
// Get output file name.
string file_name;
if (!grpc_ruby_generator::ServicesFilename(file, &file_name)) {
return false;
}
-
std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
context->Open(file_name));
google::protobuf::io::CodedOutputStream coded_out(output.get());
- string code = grpc_ruby_generator::GetServices(file);
coded_out.WriteRaw(code.data(), code.size());
return true;
}