我有一个依赖于shell脚本生成的图形文件的库。
我希望这个库在编译时能够使用shell脚本生成图形文件,这些文件应该被复制,好像它是一个'data'语句,但每当我试图让库依赖于它时genrule,我得到
在cc_library规则// graphics_assets的deps属性中 genrule rule'// graphics_assets:assets_gen_rule'在这里放错了地方 (预期cc_inc_library,cc_library,objc_library或 cc_proto_library)
答案 0 :(得分:1)
# This is the correct format.
# Here we want to run all the shader .glsl files through the program
# file_utils:archive_tool (which we also build elsewhere) and copy the
# output .arc file to the data.
# 1. List the source files
filegroup(
name = "shader_source",
srcs = glob([
"shaders/*.glsl",
]),
)
# 2. invoke file_utils::archive_tool on the shaders
genrule(
name = "shaders_gen_rule",
srcs = [":shader_source"],
outs = ["shaders.arc"],
cmd = "echo $(locations shader_source) > temp.txt ; \
$(location //common/file_utils:archive_tool) \
--create_from_list=temp.txt \
--archive $(OUTS) ; \
$(location //common/file_utils:archive_tool) \
--ls --archive $(OUTS) ",
tools = ["//common/file_utils:archive_tool"],
)
# 3. when a a binary depends on this tool the arc file will be copied.
# This is the thing I had trouble with
cc_library(
name = "shaders",
srcs = [], # Something
data = [":shaders_gen_rule"],
linkstatic = 1,
)