Documentation issue: General Rules: When to use genrule vs. rule ?
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
Documentation URL: https://docs.bazel.build/versions/master/be/general.html#genrule
This documentation lacks guidance on whether, or in what situations, a [`rule()`](https://docs.bazel.build/versions/master/skylark/rules.html) should be favored over a [`genrule()`](https://docs.bazel.build/versions/master/be/general.html#genrule) (or vice-versa).
IMHO, `rule`s are preferable because:
* They can return providers, thus allowing references to their targets to be typechecked.
* The Make variable syntax of `genrule`s is obscure and harder to look up.
* They're more explicit in general and support various `doc` fields for documentation.
* I seem to recall some quirks around inferring the relevant genrule from an output filename, but perhaps that's been fixed by now.
I guess maybe `genrule`'s terseness could be justified if the target and its generator are one-offs?
But that's just my opinion. I'd prefer official guidance from Bazel Team, hence this issue.
Contributor guide
Research direction
Start with the General Rules documentation at https://docs.bazel.build/versions/master/be/general.html#genrule and compare it with the linked rule() documentation. Review the documented capabilities and trade-offs of rule() and genrule(), then add neutral official guidance explaining when each should be used and update the relevant documentation section.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100