Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation issue: General Rules: When to use genrule vs. rule ? #12781

Open
cvrebert opened this issue Jan 6, 2021 · 3 comments
Open

Documentation issue: General Rules: When to use genrule vs. rule ? #12781

cvrebert opened this issue Jan 6, 2021 · 3 comments
Labels
help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Configurability platforms, toolchains, cquery, select(), config transitions team-Documentation Documentation improvements that cannot be directly linked to other team labels type: documentation (cleanup)

Comments

@cvrebert
Copy link
Contributor

cvrebert commented Jan 6, 2021

Documentation URL: https://docs.bazel.build/versions/master/be/general.html#genrule

This documentation lacks guidance on whether, or in what situations, a rule() should be favored over a genrule() (or vice-versa).

IMHO, rules are preferable because:

  • They can return providers, thus allowing references to their targets to be typechecked.
  • The Make variable syntax of genrules 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.

@aiuto aiuto added bad error messaging Issues where users get stuck because they don't understand what they did wrong team-Documentation Documentation improvements that cannot be directly linked to other team labels untriaged labels Jan 7, 2021
@aiuto
Copy link
Contributor

aiuto commented Jan 7, 2021

I think your judgement is spot-on there. rules are better, except for some one-offs. We need more documentation about the trade-offs.

@aiuto aiuto removed the bad error messaging Issues where users get stuck because they don't understand what they did wrong label Jan 7, 2021
@floriographygoth floriographygoth added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Feb 8, 2021
@floriographygoth
Copy link
Contributor

Thanks! We will update the Build Encyclopedia and take a look for the correct home for conceptual information regarding rule vs. genrule tradeoffs.

@aiuto
Copy link
Contributor

aiuto commented Feb 9, 2021 via email

@sgowroji sgowroji added the team-Configurability platforms, toolchains, cquery, select(), config transitions label Nov 22, 2022
@keertk keertk added P3 We're not considering working on this, but happy to review a PR. (No assignee) help wanted Someone outside the Bazel team could own this and removed P2 We'll consider working on this in future. (Assignee optional) labels Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Configurability platforms, toolchains, cquery, select(), config transitions team-Documentation Documentation improvements that cannot be directly linked to other team labels type: documentation (cleanup)
Projects
None yet
Development

No branches or pull requests

6 participants