Skip to content

Commit

Permalink
genrule doc points to run_binary
Browse files Browse the repository at this point in the history
Many new usages of `genrule` should be avoided, as `run_binary` says:
> Runs a binary as a build action. This rule does not require Bash (unlike native.genrule()).

Even when `genrule` starts hermetic, it's easy to accidentally grow into a longer bash script after subsequent changes.

Closes bazelbuild#16779.

PiperOrigin-RevId: 491308775
Change-Id: I92df653e3a8a4c592d9fc8e5bc7497eda71789a4
  • Loading branch information
alexeagle authored and copybara-github committed Nov 28, 2022
1 parent 0c52ef6 commit 3b4e5ec
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ public RuleDefinition.Metadata getMetadata() {
to the existing <code>cc_*</code> rules, because all the heavy lifting has already been done
for you.
</p>
<p>
Note that genrule requires a shell to interpret the command argument.
It is also easy to reference arbitrary programs available on the PATH, however this makes the
command non-hermetic and may not be reproducible.
If you only need to run a single tool, consider using
<a href="https://github.com/bazelbuild/bazel-skylib/blob/main/docs/run_binary_doc.md">run_binary</a>
instead.
<p>
Do not use a genrule for running tests. There are special dispensations for tests and test
results, including caching policies and environment variables. Tests generally need to be run
Expand Down

0 comments on commit 3b4e5ec

Please sign in to comment.