aboutsummaryrefslogtreecommitdiff
path: root/protobuf.bzl
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2015-10-20 15:18:20 -0700
committerJisi Liu <jisi.liu@gmail.com>2015-10-20 15:18:20 -0700
commit53a56be4c49174bc2697d648b3d41ff141fee1d7 (patch)
treea87b20c034913c8f0ceaf4e3a603456989a2cd0a /protobuf.bzl
parent04658a3c24e1f4b7e1142843bb0a33d55e4f821f (diff)
downloadprotobuf-53a56be4c49174bc2697d648b3d41ff141fee1d7.tar.gz
protobuf-53a56be4c49174bc2697d648b3d41ff141fee1d7.tar.bz2
protobuf-53a56be4c49174bc2697d648b3d41ff141fee1d7.zip
Change the impl rule include to includes.
We need to use the list to indicate field presense. The field must only contain 0 or 1 string element.
Diffstat (limited to 'protobuf.bzl')
-rw-r--r--protobuf.bzl34
1 files changed, 22 insertions, 12 deletions
diff --git a/protobuf.bzl b/protobuf.bzl
index c7d66086..1fc20dda 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -1,13 +1,13 @@
# -*- mode: python; -*- PYTHON-PREPROCESSING-REQUIRED
def _GenDir(ctx):
- if ctx.attr.include == None:
+ if not ctx.attr.includes:
return ""
- if not ctx.attr.include:
+ if not ctx.attr.includes[0]:
return ctx.label.package
if not ctx.label.package:
- return ctx.attr.include
- return ctx.label.package + '/' + ctx.attr.include
+ return ctx.attr.includes[0]
+ return ctx.label.package + '/' + ctx.attr.includes[0]
def _CcOuts(srcs):
return [s[:-len(".proto")] + ".pb.h" for s in srcs] + \
@@ -44,7 +44,11 @@ def _proto_gen_impl(ctx):
deps = []
deps += ctx.files.srcs
gen_dir = _GenDir(ctx)
- import_flags = ["-I" + gen_dir]
+ if gen_dir:
+ import_flags = ["-I" + gen_dir]
+ else:
+ import_flags = ["-I."]
+
for dep in ctx.attr.deps:
import_flags += dep.proto.import_flags
deps += dep.proto.deps
@@ -75,7 +79,7 @@ _proto_gen = rule(
attrs = {
"srcs": attr.label_list(allow_files = True),
"deps": attr.label_list(providers = ["proto"]),
- "include": attr.string(),
+ "includes": attr.string_list(),
"protoc": attr.label(
executable = True,
single_file = True,
@@ -116,6 +120,10 @@ def cc_proto_library(
"""
+ includes = []
+ if include != None:
+ includes = [include]
+
if internal_bootstrap_hack:
# For pre-checked-in generated files, we add the internal_bootstrap_hack
# which will skip the codegen action.
@@ -123,7 +131,7 @@ def cc_proto_library(
name=name + "_genproto",
srcs=srcs,
deps=[s + "_genproto" for s in deps],
- include=include,
+ includes=includes,
protoc=protoc,
)
# An empty cc_library to make rule dependency consistent.
@@ -137,15 +145,12 @@ def cc_proto_library(
name=name + "_genproto",
srcs=srcs,
deps=[s + "_genproto" for s in deps],
- include=include,
+ includes=includes,
protoc=protoc,
gen_cc=1,
outs=outs,
)
- includes = []
- if include != None:
- includes = [include]
native.cc_library(
name=name,
@@ -210,11 +215,16 @@ def py_proto_library(
"""
outs = _PyOuts(srcs)
+
+ includes = []
+ if include != None:
+ includes = [include]
+
_proto_gen(
name=name + "_genproto",
srcs=srcs,
deps=[s + "_genproto" for s in deps],
- include=include,
+ includes=includes,
protoc=protoc,
gen_py=1,
outs=outs,