bazelbuild/bazel

Please fix the genrule documentation!

Open

#13,338 创建于 2021年4月13日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Java (4,465 fork)batch import
P3help wantedteam-Documentationteam-Rules-CPPtype: documentation (cleanup)

仓库指标

Star
 (25,384 star)
PR 合并指标
 (平均合并 22天 20小时) (30 天内合并 77 个 PR)

描述

Description of the problem / feature request:

It's way too hard to figure out how to use genrules for the trivial case of generating and depending on multiple c header files. I have a very simple cc_binary rule that needs headers generated by:

genrule(
    name = "mkhdrs",
    srcs = ["obazl.c","fs_utils.c"],
    outs = ["obazl.h","fs_utils.h"],
    cmd = "\n".join([
        "$(location :makeheaders) coq/*.c;",
        "cp coq/*.h $(@D)"
    ]),
    tools = [":makeheaders"]
)

By trial and error I discovered this works:

    copts = ["-I", "bazel-out/darwin-fastbuild/bin/coq"]

which is obviously a hack. After too much time searching the web, I found:

    copts = ["-I", "$(GENDIR)/coq"],

This is very obscure, but only because the documentation is so spare. At the least I recommend adding something like this to the "Examples" section of genrule

Feature requests: what underlying problem are you trying to solve with this feature?

Inadequate documentation.

Have you found anything relevant by searching the web?

Yes, but the point is this sort of base case should not require web searching.

贡献者指南