-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed as not planned
Closed as not planned
Copy link
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)incompatible-changeIncompatible/breaking changeIncompatible/breaking changestaleIssues or PRs that are stale (no activity for 30 days)Issues or PRs that are stale (no activity for 30 days)team-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactsAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: process
Description
This flag disables the outputs parameter on the rule() function.
Flag: --incompatible_no_rule_outputs_param
Motivation
Output Map Madness outlines some problems and inconsistencies in using this pattern, and there are also a couple of github issues (#2883 and #5581) on this matter.
Additional details in #6241
Migration
Use OutputGroupInfo specify output files instead.
For example, replace:
def _my_rule_impl(ctx):
...
my_rule = rule(
implementation = _my_rule_impl,
outputs = {“bin”: “%{name}.exe”},
)with:
def _rule_impl(ctx):
...
bin_name = ctx.attr.name + “.exe”
bin_output = ctx.actions.declare_file(bin_name)
# bin_output will, as before, need to be the output of an action
...
return [OutputGroupInfo(bin = depset([bin_output])]
my_rule = rule(
implementation = _my_rule_impl,
)Note that this migration approach does not automatically let you specify these outputs by label. For example, you will notice that, with this exact approach, you cannot specify the ".exe"-suffix as its own label.
In order to preserve this implicit-output functionality, you will need to use attr.output with a macro-specified default. For example:
def _rule_impl(ctx):
...
bin_output = ctx.outputs.bin_output
# bin_output will, as before, need to be the output of an action
...
return [OutputGroupInfo(bin = depset([bin_output])]
_my_rule = rule(
implementation = _my_rule_impl,
attrs = {
"bin_output" : attr.output(),
}
)
def my_rule(name, **kwargs):
my_rule(name = name,
bin_output = name + ".exe",
**kwargs)Reactions are currently unavailable
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)incompatible-changeIncompatible/breaking changeIncompatible/breaking changestaleIssues or PRs that are stale (no activity for 30 days)Issues or PRs that are stale (no activity for 30 days)team-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactsAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: process