最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

bazel - How to write default for label attribute of a rule such that it will be searched in calling package? - Stack Overflow

programmeradmin1浏览0评论

Say I have a rule like this, defined in a package //rules:

myrule = rule(
    implementation = _impl,
    attrs = {
        "label": attr.label(default = ":default.txt", mandatory = True),
    },
)

Then I call it from another package, //caller, like this:

myrule(name = "mytarget")

Bazel will complain that /package/default.txt does not exist, but I want it to use /caller/default.txt. I can accomplish this using a macro instead:

def mymacro(label = ":default.txt", **kwargs):
    myrule(label = label, **kwargs)

But is there a way I can accomplish it without the macro, by writing the default value in a different way?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论