1

尝试构建时,我不断收到错误“没有这样的文件或目录 myheader.h”。我在这里做一些概念上的错误吗?我不明白为什么它找不到标题,我真的不认为我应该添加一个-Ibazel-out/k8-fastbuild/genfiles/mylibrarycopts,因为该路径会根据命令行参数而变化。

# 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
)
4

1 回答 1

2

好的,似乎规范的方式是真正做到:copts = ["-I$(GENDIR)/myprojectdir"]

于 2019-01-28T14:57:25.887 回答