aboutsummaryrefslogtreecommitdiff
path: root/protobuf.bzl
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2015-10-16 12:46:26 -0700
committerJisi Liu <jisi.liu@gmail.com>2015-10-16 12:46:26 -0700
commit3101e7337cdade287bdba97dd7c08ee5d4c14587 (patch)
tree7ea0a99f2bb17f0409e8bbfde35a5d0ea94f2a15 /protobuf.bzl
parentd8701b5741a668c5f2b4781b12f5d5517e38b9e7 (diff)
downloadprotobuf-3101e7337cdade287bdba97dd7c08ee5d4c14587.tar.gz
protobuf-3101e7337cdade287bdba97dd7c08ee5d4c14587.tar.bz2
protobuf-3101e7337cdade287bdba97dd7c08ee5d4c14587.zip
Change prefix to include, and add docs
Diffstat (limited to 'protobuf.bzl')
-rw-r--r--protobuf.bzl37
1 files changed, 27 insertions, 10 deletions
diff --git a/protobuf.bzl b/protobuf.bzl
index c6685d30..79dabd02 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -1,11 +1,11 @@
# -*- mode: python; -*- PYTHON-PREPROCESSING-REQUIRED
def _gen_dir(ctx):
- if not ctx.attr.prefix:
+ if not ctx.attr.include:
return ctx.label.package
if not ctx.label.package:
- return ctx.attr.prefix
- return ctx.label.package + '/' + ctx.attr.prefix
+ return ctx.attr.include
+ return ctx.label.package + '/' + ctx.attr.include
def _cc_outs(srcs):
return [s[:-len(".proto")] + ".pb.h" for s in srcs] + \
@@ -51,7 +51,7 @@ _proto_gen = rule(
attrs = {
"srcs": attr.label_list(allow_files = True),
"deps": attr.label_list(providers = ["proto"]),
- "prefix": attr.string(),
+ "include": attr.string(),
"protoc": attr.label(
executable = True,
single_file = True,
@@ -68,12 +68,29 @@ _proto_gen = rule(
def cc_proto_library(
name,
srcs=[],
- protoc=":protoc",
- internal_bootstrap_hack=False,
- prefix="",
deps=[],
cc_libs=[],
+ include="",
+ protoc=":protoc",
+ internal_bootstrap_hack=False,
**kargs):
+ """Bazel rule to create a C++ protobuf library from proto source files
+
+ Args:
+ name: the name of the cc_proto_library.
+ srcs: the .proto files of the cc_proto_library.
+ deps: a list of dependency labels; must be cc_proto_library.
+ cc_libs: a list of other cc_library targets depended by the generated
+ cc_library.
+ include: a string indicating the include path of the .proto files.
+ protoc: the label of the protocol compiler to generate the sources.
+ internal_bootstrap_hack: a flag indicate the cc_proto_library is used only
+ for bootstraping. When it is set to True, no files will be generated.
+ The rule will simply be a provider for .proto files, so that other
+ cc_proto_library can depend on it.
+ **kargs: other keyword arguments that are passed to cc_library.
+
+ """
if internal_bootstrap_hack:
# For pre-checked-in generated files, we add the internal_bootstrap_hack
@@ -82,7 +99,7 @@ def cc_proto_library(
name=name + "_genproto",
srcs=srcs,
deps=[s + "_genproto" for s in deps],
- prefix=prefix,
+ include=include,
protoc=protoc,
)
# An empty cc_library to make rule dependency consistent.
@@ -96,7 +113,7 @@ def cc_proto_library(
name=name + "_genproto",
srcs=srcs,
deps=[s + "_genproto" for s in deps],
- prefix=prefix,
+ include=include,
protoc=protoc,
gen_cc=1,
outs=outs,
@@ -106,5 +123,5 @@ def cc_proto_library(
name=name,
srcs=outs,
deps=cc_libs + deps,
- includes=[prefix],
+ includes=[include],
**kargs)