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.
This commit is contained in:
Jisi Liu 2015-10-20 15:18:20 -07:00
parent 04658a3c24
commit 53a56be4c4
2 changed files with 29 additions and 19 deletions

14
BUILD
View File

@ -124,13 +124,13 @@ cc_library(
deps = [":protobuf_lite"],
)
objc_library(
name = "protobuf_objc",
hdrs = ["objectivec/GPBProtocolBuffers.h"],
includes = ["objectivec"],
non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
visibility = ["//visibility:public"],
)
# objc_library(
# name = "protobuf_objc",
# hdrs = ["objectivec/GPBProtocolBuffers.h"],
# includes = ["objectivec"],
# non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
# visibility = ["//visibility:public"],
# )
RELATIVE_WELL_KNOWN_PROTOS = [
# AUTOGEN(well_known_protos)

View File

@ -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,