提交 c93ca648 编写于 作者: W wangguibao

Fix pdcodegen

上级 ac85c41f
...@@ -95,40 +95,38 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -95,40 +95,38 @@ class PdsCodeGenerator : public CodeGenerator {
const string body = strip_proto(file->name()) + ".pb.cc"; const string body = strip_proto(file->name()) + ".pb.cc";
bool include_inserted = false; bool include_inserted = false;
for (int i = 0; i < file->service_count(); ++i) { for (int i = 0; i < file->service_count(); ++i) {
const ServiceDescriptor* descriptor = file->service(i); const ServiceDescriptor* descriptor = file->service(i);
if (!descriptor) { if (!descriptor) {
*error = "get descriptor failed"; *error = "get descriptor failed";
return false; return false;
} }
pds::PaddleServiceOption options = pds::PaddleServiceOption options =
descriptor->options().GetExtension(pds::options); descriptor->options().GetExtension(pds::options);
bool generate_impl = options.generate_impl(); bool generate_impl = options.generate_impl();
bool generate_stub = options.generate_stub(); bool generate_stub = options.generate_stub();
if (!generate_impl && !generate_stub) { if (!generate_impl && !generate_stub) {
return true; return true;
}
if (!include_inserted) {
boost::scoped_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
context->OpenForInsert(header, "includes"));
google::protobuf::io::Printer printer(output.get(), '$');
if (generate_impl) {
printer.Print("#include \"predictor/common/inner_common.h\"\n");
printer.Print("#include \"predictor/framework/service.h\"\n");
printer.Print("#include \"predictor/framework/manager.h\"\n");
printer.Print("#include \"predictor/framework/service_manager.h\"\n");
} }
if (generate_stub) {
if (!include_inserted) { printer.Print("#include <baidu/rpc/parallel_channel.h>\n");
boost::scoped_ptr<google::protobuf::io::ZeroCopyOutputStream> output( printer.Print("#include \"sdk-cpp/include/factory.h\"\n");
context->OpenForInsert(header, "includes")); printer.Print("#include \"sdk-cpp/include/stub.h\"\n");
google::protobuf::io::Printer printer(output.get(), '$'); printer.Print("#include \"sdk-cpp/include/stub_impl.h\"\n");
if (generate_impl) {
printer.Print("#include \"predictor/common/inner_common.h\"\n");
printer.Print("#include \"predictor/framework/service.h\"\n");
printer.Print("#include \"predictor/framework/manager.h\"\n");
printer.Print("#include \"predictor/framework/service_manager.h\"\n");
}
if (generate_stub) {
printer.Print("#include <baidu/rpc/parallel_channel.h>\n");
printer.Print("#include \"sdk-cpp/include/factory.h\"\n");
printer.Print("#include \"sdk-cpp/include/stub.h\"\n");
printer.Print("#include \"sdk-cpp/include/stub_impl.h\"\n");
}
include_inserted = true;
} }
include_inserted = true;
const std::string& class_name = descriptor->name(); }
const std::string& service_name = descriptor->name(); const std::string& class_name = descriptor->name();
const std::string& service_name = descriptor->name();
// xxx.ph.h // xxx.ph.h
{ {
if (generate_impl) { if (generate_impl) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册