有没有什么办法可以在 genrule 的路径中包含带有爆炸(!)的文件?
Is there any way to include a file with a bang (!) in the path in a genrule?
我有一个 iOS 框架,它依赖于名为“!ProtoCompiler”的(大概是 Google 维护的)pod。为了构建我的框架,我需要在沙箱中使用它。所以,我有一个 genrule,可以尝试将它包含在
src = glob(['Pods/!ProtoCompiler/**/*'])
但出现以下错误:
ERROR: BUILD:2:1: //Foo:framework-debug: invalid label 'Pods/!ProtoCompiler/google/protobuf/any.proto' in element 1118 of attribute 'srcs' in 'genrule' rule: invalid target name 'Pods/!ProtoCompiler/google/protobuf/any.proto': target names may not contain '!'.
事实上,这对我使用 bazel 进行此构建来说似乎是一个完全的障碍。据我所知,我无法重命名 pod 目录。据我所知,!禁止应该是针对 target 标签,有什么办法可以指定这只是一个文件,而不是标签?或者这两个概念完全融合在 bazel 中?
(此外,如果我让它工作,我担心这会产生一个 .framework 目录,而且看起来规则应该只产生文件。也许我会把它压缩然后解压缩它作为测试工具构建的一部分。)
As far as I can tell, the ! prohibition is supposed to be for target
labels, is there any way I can specify that this is just a file, not a
label? Or are those two concepts completely melded in bazel?
它们大多是模制的。
Bazel 将标签与出现在 BUILD 文件中的包中的所有源文件相关联,因此您可以在构建规则中写入 srcs=["foo.cc", "//bar:baz.cc"]
,无论 foo.cc
和 baz.cc
是源文件、生成的文件或生成适合此特定 srcs
属性的文件的构建规则的名称。
也就是说你当然可以在包中包含任何文件,但是如果名称不允许 Bazel 从中派生标签,那么你就不能在 BUILD 文件中引用它们。由于 glob
在加载期间进行计算并扩展为标签列表,因此使用 glob
将无法解决此限制。
(...) it seems like rules are expected to produces files only. Maybe
I'll zip it up and then unzip it as part of the build of the test
harness.
是的,这是通常的方法。
我有一个 iOS 框架,它依赖于名为“!ProtoCompiler”的(大概是 Google 维护的)pod。为了构建我的框架,我需要在沙箱中使用它。所以,我有一个 genrule,可以尝试将它包含在
src = glob(['Pods/!ProtoCompiler/**/*'])
但出现以下错误:
ERROR: BUILD:2:1: //Foo:framework-debug: invalid label 'Pods/!ProtoCompiler/google/protobuf/any.proto' in element 1118 of attribute 'srcs' in 'genrule' rule: invalid target name 'Pods/!ProtoCompiler/google/protobuf/any.proto': target names may not contain '!'.
事实上,这对我使用 bazel 进行此构建来说似乎是一个完全的障碍。据我所知,我无法重命名 pod 目录。据我所知,!禁止应该是针对 target 标签,有什么办法可以指定这只是一个文件,而不是标签?或者这两个概念完全融合在 bazel 中?
(此外,如果我让它工作,我担心这会产生一个 .framework 目录,而且看起来规则应该只产生文件。也许我会把它压缩然后解压缩它作为测试工具构建的一部分。)
As far as I can tell, the ! prohibition is supposed to be for target labels, is there any way I can specify that this is just a file, not a label? Or are those two concepts completely melded in bazel?
它们大多是模制的。
Bazel 将标签与出现在 BUILD 文件中的包中的所有源文件相关联,因此您可以在构建规则中写入 srcs=["foo.cc", "//bar:baz.cc"]
,无论 foo.cc
和 baz.cc
是源文件、生成的文件或生成适合此特定 srcs
属性的文件的构建规则的名称。
也就是说你当然可以在包中包含任何文件,但是如果名称不允许 Bazel 从中派生标签,那么你就不能在 BUILD 文件中引用它们。由于 glob
在加载期间进行计算并扩展为标签列表,因此使用 glob
将无法解决此限制。
(...) it seems like rules are expected to produces files only. Maybe I'll zip it up and then unzip it as part of the build of the test harness.
是的,这是通常的方法。