diff options
-rw-r--r-- | protobuf.bzl | 12 | ||||
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_file.cc | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/protobuf.bzl b/protobuf.bzl index 6ae5a594..3998e77b 100644 --- a/protobuf.bzl +++ b/protobuf.bzl @@ -299,6 +299,7 @@ def py_proto_library( include=None, default_runtime="//:protobuf_python", protoc="//:protoc", + use_grpc_plugin=False, **kargs): """Bazel rule to create a Python protobuf library from proto source files @@ -318,6 +319,8 @@ def py_proto_library( default_runtime: the implicitly default runtime which will be depended on by the generated py_library target. protoc: the label of the protocol compiler to generate the sources. + use_grpc_plugin: a flag to indicate whether to call the Python C++ plugin + when processing the proto files. **kargs: other keyword arguments that are passed to cc_library. """ @@ -327,6 +330,13 @@ def py_proto_library( if include != None: includes = [include] + grpc_python_plugin = None + if use_grpc_plugin: + grpc_python_plugin = "//external:grpc_python_plugin" + # Note: Generated grpc code depends on Python grpc module. This dependency + # is not explicitly listed in py_libs. Instead, host system is assumed to + # have grpc installed. + proto_gen( name=name + "_genproto", srcs=srcs, @@ -336,6 +346,8 @@ def py_proto_library( gen_py=1, outs=outs, visibility=["//visibility:public"], + plugin=grpc_python_plugin, + plugin_language="grpc" ) if default_runtime and not default_runtime in py_libs + deps: diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 63aee4ff..bc664c70 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -765,7 +765,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); if (!StaticInitializersForced(file_, options_)) { - printer->Print("#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); + printer->Print("#ifndef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); } printer->Print( // With static initializers. |