首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >bazel找不到生成的标头

bazel找不到生成的标头
EN

Stack Overflow用户
提问于 2019-01-28 13:14:20
回答 1查看 185关注 0票数 1

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

代码语言:javascript
运行
复制
# 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
)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-28 22:57:26

好的,看起来规范的方法是真的这样做:copts = ["-I$(GENDIR)/myprojectdir"]

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54395885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档