aboutsummaryrefslogtreecommitdiff
path: root/protobuf.bzl
diff options
context:
space:
mode:
authorManjunath Kudlur <keveman@gmail.com>2016-02-25 08:50:50 -0800
committerManjunath Kudlur <keveman@gmail.com>2016-02-25 08:50:50 -0800
commitf5c736352ed453310438a9ffc5056cdd0c4b25b4 (patch)
tree79cf3d863db244803c399ced32c5f1bb24c41129 /protobuf.bzl
parentcc775f7ac1589eda26fc65602d228baef8001944 (diff)
downloadprotobuf-f5c736352ed453310438a9ffc5056cdd0c4b25b4.tar.gz
protobuf-f5c736352ed453310438a9ffc5056cdd0c4b25b4.tar.bz2
protobuf-f5c736352ed453310438a9ffc5056cdd0c4b25b4.zip
Fixed grpc C++ plugin support.
grpc C++ plugin generates additional files, namely .grpc.pb.cc and .grpc.pb.h. Adding these files to the outs of the _proto_gen rule, so dependents don't complain about undeclared inclusions. Also, compiling the .grpc.pb.cc requires additional header files from the grpc library, so added //external:grpc_lib to the deps of the cc_library. Clients are expected to declare that in their bazel WORKSPACE, pointing it to @grpc//:grpc++{_unsecure}.
Diffstat (limited to 'protobuf.bzl')
-rw-r--r--protobuf.bzl17
1 files changed, 11 insertions, 6 deletions
diff --git a/protobuf.bzl b/protobuf.bzl
index 399cf624..e5af3339 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -15,9 +15,13 @@ def _GenDir(ctx):
return _GetPath(ctx, ctx.attr.includes[0])
return _GetPath(ctx, ctx.label.package + '/' + ctx.attr.includes[0])
-def _CcOuts(srcs):
- return [s[:-len(".proto")] + ".pb.h" for s in srcs] + \
- [s[:-len(".proto")] + ".pb.cc" for s in srcs]
+def _CcOuts(srcs, use_grpc_plugin=False):
+ ret = [s[:-len(".proto")] + ".pb.h" for s in srcs] + \
+ [s[:-len(".proto")] + ".pb.cc" for s in srcs]
+ if use_grpc_plugin:
+ ret += [s[:-len(".proto")] + ".grpc.pb.h" for s in srcs] + \
+ [s[:-len(".proto")] + ".grpc.pb.cc" for s in srcs]
+ return ret
def _PyOuts(srcs):
return [s[:-len(".proto")] + "_pb2.py" for s in srcs]
@@ -169,7 +173,8 @@ def cc_proto_library(
if use_grpc_plugin:
grpc_cpp_plugin = "//external:grpc_cpp_plugin"
- outs = _CcOuts(srcs)
+ outs = _CcOuts(srcs, use_grpc_plugin)
+
_proto_gen(
name=name + "_genproto",
srcs=srcs,
@@ -184,6 +189,8 @@ def cc_proto_library(
if default_runtime and not default_runtime in cc_libs:
cc_libs += [default_runtime]
+ if use_grpc_plugin:
+ cc_libs += ["//external:grpc_lib"]
native.cc_library(
name=name,
@@ -192,7 +199,6 @@ def cc_proto_library(
includes=includes,
**kargs)
-
def internal_copied_filegroup(
name,
srcs,
@@ -222,7 +228,6 @@ def internal_copied_filegroup(
srcs=outs,
**kargs)
-
def py_proto_library(
name,
srcs=[],