bazelbuild / bazelbuild/bazel

[bazel.build] Problem with /reference/be/general

Open
#18,411 2 comments 0 reactions 0 assignees View on GitHub
help wanted P3 team-Configurability team-Documentation type: documentation (cleanup)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Page link:

https://bazel.build/reference/be/general

### Problem description (include actual vs expected text, if applicable):

I think the genrule examples should be clearer in explaining the difference between `srcs` and `tools` especially because genrule `srcs` are different from `srcs` in most other rules. I assumed that `srcs` would be interpreted as something executable if the target pointed to an executable because the docs mention that all prereqs are built before running the genrule, but that's not really how it works.

`
genrule(
name = "concat_all_files",
srcs = [
"//some:files", # a filegroup with multiple files in it ==> $(locations)
"//other:gen", # a genrule with a single output ==> $(location)
],
outs = ["concatenated.txt"],
cmd = "cat $(locations //some:files) $(location //other:gen) > $@",
)
`
I when I read this I thought `//some:files` could potentially be targets that produce runfiles but they should not be. Further down the page in the `srcs` section
`This attributes is not suitable to list tools executed by the cmd; use the [tools](https://bazel.build/reference/be/general#genrule.tools) attribute for them instead.
`
I assumed this referred to files being executed by *srcs* in `cmd` (like a script calling another tool), not whatever is getting executed by bash. Maybe a quick example that explicitly rules out calling `srcs` in `cmd` would make it clearer.

### Where do you see this issue? (include link to specific section of the page, if applicable)

https://bazel.build/reference/be/general#genrule_examples

### Any other information you'd like to share?

If you are seeing "Cannot find .runfiles directory" this mistake might be why

Contributor guide

Open the contributing guide

Research direction

Start at https://bazel.build/reference/be/general#genrule_examples and read the genrule srcs and tools attribute sections together. Clarify the example so it distinguishes inputs from executable tools and explains that srcs targets are not runfiles-based tools. Done when the example and surrounding text remove the ambiguity described in the issue.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.