-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Implicit outputs feature is underdocumented #2882
Copy link
Copy link
Closed as not planned
Labels
P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)This is either out of scope or we don't have bandwidth to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)Issues or PRs that are stale (no activity for 30 days)team-DocumentationDocumentation improvements that cannot be directly linked to other team labelsDocumentation improvements that cannot be directly linked to other team labelsteam-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactsAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: documentation (cleanup)
Metadata
Metadata
Assignees
Labels
P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)This is either out of scope or we don't have bandwidth to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)Issues or PRs that are stale (no activity for 30 days)team-DocumentationDocumentation improvements that cannot be directly linked to other team labelsDocumentation improvements that cannot be directly linked to other team labelsteam-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactsAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: documentation (cleanup)
(originally reported by @alandonovan)
The documentation at
https://bazel.build/versions/master/docs/skylark/lib/globals.html#parameters-22 is vague. It should answer the following questions:
Peeking at the implementation, the answers appear to be:
if it's empty, there are no implicit outputs.
otherwise the sole member of the cross product is used.
All this begs the question: what's the point of the cross-product logic if the resulting set has at most one element?
Also: why is it that the 'implicit outputs' function has access to whichever attributes it wants through its parameters AND returns a dict of templates "%{name}-%{srcs}.x" that are then subject to further attribute expansion? It seems redundant.
There are not one but three ad-hoc conversion processes here:
Ideally there would be one (clearly documented) conversion from attributes to Skylark values to replace #1 and #2. #3 would be replaced by an extremely simple conversion such as "%s" recursively applied to each Skylark value. Anything else---dirname, basename; removal of files extensions, etc) should be done by writing Skylark logic.
Users do not have to write output functions very often. It is better to make them explicit than concise, and doing so lets you simplify the implementation and the spec.