aboutsummaryrefslogtreecommitdiff
path: root/protobuf.bzl
diff options
context:
space:
mode:
authorWiktor Tomczak <wiktor.tomczak@gmail.com>2016-11-22 20:18:46 +0100
committerWiktor Tomczak <wiktor.tomczak@gmail.com>2016-11-22 20:21:10 +0100
commit0fa31b2bfae069b764c4fa7c702c5627c5c6f9e1 (patch)
tree4ab7856712d85f7e3c34b26a2dfa6c658dfb0221 /protobuf.bzl
parentb7632464b4efd2f8a8285bd4bfd0fa5157fdeb2d (diff)
downloadprotobuf-0fa31b2bfae069b764c4fa7c702c5627c5c6f9e1.tar.gz
protobuf-0fa31b2bfae069b764c4fa7c702c5627c5c6f9e1.tar.bz2
protobuf-0fa31b2bfae069b764c4fa7c702c5627c5c6f9e1.zip
Support grpc plugin in py_proto_library
Diffstat (limited to 'protobuf.bzl')
-rw-r--r--protobuf.bzl12
1 files changed, 12 insertions, 0 deletions
diff --git a/protobuf.bzl b/protobuf.bzl
index ac448201..74cb9ad5 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -304,6 +304,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
@@ -323,6 +324,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.
"""
@@ -332,6 +335,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,
@@ -341,6 +351,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: