bazelbuild / bazelbuild/bazel

Please fix the genrule documentation!

Open
#13,338 1 comment 0 reactions 0 assignees View on GitHub
help wanted P3 team-Documentation team-Rules-CPP type: documentation (cleanup)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### 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](https://docs.bazel.build/versions/master/be/general.html#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.

Contributor guide

Open the contributing guide

Research direction

Start with the linked genrule documentation, especially its Examples section, and review the provided multiple-generated-header case. Document the $(GENDIR)/coq usage alongside the genrule example and explain how the generated headers are made available to the cc_binary; done means this base case is clear without web searching.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.