我创建了一个文件组规则,在一个标签中包含库的所有.proto文件。
filegroup(
name = "protos_all_src",
srcs = glob(
["**/*.proto"],
exclude = [
"protobuf/worker.proto",
"protobuf/worker_service.proto",
"protobuf/master.proto",
"protobuf/master_service.proto",
],
)
)
tf_proto_library(
name = "protos_all",
srcs = ":protos_all_src",
),
...
)
但奇怪的是这种格式的另一条规则失败了:
cc_library(
name = "lib_internal",
srcs = glob(
[
"lib/**/*.h",
"lib/**/*.cc",
"platform/*.h",
"platform/*.cc",
] + tf_additional_lib_srcs(),
exclude = [
"**/*test*",
"platform/**/cuda.h",
"platform/**/stream_executor.h",
],
),
hdrs = [
"lib/core/blocking_counter.h",
"lib/core/refcount.h",
"lib/gtl/edit_distance.h",
"lib/gtl/int_type.h",
"lib/gtl/iterator_range.h",
"lib/gtl/manual_constructor.h",
"lib/gtl/top_n.h",
"lib/io/iterator.h",
"lib/io/match.h",
"lib/jpeg/jpeg_handle.h",
"lib/png/png_io.h",
"lib/random/random.h",
"lib/random/random_distributions.h",
"lib/random/weighted_picker.h",
"lib/strings/ordered_code.h",
"lib/strings/proto_text_util.h",
"lib/strings/regexp.h",
"lib/strings/scanner.h",
"lib/wav/wav_io.h",
"platform/demangle.h",
"platform/denormal.h",
"platform/platform.h",
"platform/tensor_coding.h",
"platform/tracing.h",
],
copts = tf_copts(),
linkopts = ["-ldl"],
deps = [
":protos_all_cc",
"//tensorflow/core/platform/default/build_config:platformlib",
"//third_party/eigen3",
],
)
请注意protos_all_cc规则为dep。
如果我回到
tf_proto_library(
name = "protos_all",
srcs = glob(
["**/*.proto"],
exclude = [
"protobuf/worker.proto",
"protobuf/worker_service.proto",
"protobuf/master.proto",
"protobuf/master_service.proto",
],
),
一切正常。
我希望第一种和第二种格式完全相同。我缺少什么?
编辑:
此处定义tf_proto_library
:
并且此处定义了cc_proto_library
:
https://github.com/google/protobuf/blob/master/protobuf.bzl#L109
bazel版本:
Build label: 0.2.3-homebrew
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue May 17 15:07:52 2016 (1463497672)
Build timestamp: 1463497672
Build timestamp as int: 1463497672
答案 0 :(得分:1)
您可以粘贴实际代码和您收到的错误消息吗?看起来有几个问题,我不确定哪些是复制粘贴错误,哪些是代码。
我猜你遇到的问题是你不能在cc_library规则中将文件(也不是文件组)列为deps
,而":protos_all_cc"
是一个文件组。 deps
必须是其他cc_libraries(它是“此规则应链接在一起的内容”)。但是很难说出错误信息和protos_all_cc的定义。
答案 1 :(得分:0)
srcs
属性应该是一个列表,因此您对protos_all
的定义应为
tf_proto_library(
name = "protos_all",
srcs = [":protos_all_src"], # note the list here
...
)
也许这只是问题中的一个错字,真正的问题是别的吗?
当我尝试Permission denied
方法时,我会遇到奇怪的filegroup
问题。