在尝试构建时,我不断收到错误消息“没有这样的文件或目录myheader.h”。我在这里做错了吗?我不明白为什么找不到标题,我真的不认为应该添加-Ibazel-out/k8-fastbuild/genfiles/mylibrary
副本,因为该路径根据命令行参数而变化。
# BUILD file
load(":size.bzl", "size")
size(
name = "blubhdrs",
infiles = [
"myheader.h", # generates new file with the same name in genfiles
]
)
cc_library(
name = "mylibrary",
hdrs = [
":blubhdrs"
],
srcs = [ "bla.cpp" ] # depends on generated header from :blubhdrs
)
# size.bzl
def _impl(ctx):
outputfiles = []
for input in ctx.files.infiles:
name = input.basename
myoutputfile = ctx.actions.declare_file(name)
outputfiles.append(myoutputfile)
# huge command, not important so I commented it out:
# ctx.actions.run_shell(...)
return DefaultInfo(files = depset(items = outputfiles))
size = rule(
implementation = _impl,
attrs = {
"infiles": attr.label_list(allow_files = True),
},
output_to_genfiles = True
)
答案 0 :(得分:2)
好吧,似乎规范的方法是真正做到:copts = ["-I$(GENDIR)/myprojectdir"]