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

incompatible_no_output_attr_default: Disable default parameter of output attributes #7950

Closed
c-parsons opened this issue Apr 4, 2019 · 0 comments
Assignees
Labels
incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required)

Comments

@c-parsons
Copy link
Contributor

This flag disables the default parameter on attr.output and attr.output_list.

Flag: --incompatible_no_output_attr_default
Available since: 0.23 (February 2019 release)

Motivation
The previous default parameter of these attribute types was severely bug-prone, as two targets of the same rule would be unable to exist in the same package under default behavior. (Two targets both generating foo.txt in the same package would conflict.)

Additional details in #6241

Migration
Use Starlark macros to specify defaults for these attributes instead.

For example, replace:

my_rule = rule(
    ...
    attrs = {"out" : attr.output(default = "foo.txt")}
    ...

with:

# myrule.bzl
my_rule = rule(
    ...
    attrs = {"out" : attr.output()}
    ...

# mymacro.bzl
load(":myrule.bzl", _my_rule = "my_rule")

def my_rule(name):
    _my_rule(
        name = name,
        output = "%s_out.txt" % name
    )
@c-parsons c-parsons self-assigned this Apr 4, 2019
@c-parsons c-parsons added incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required) team-Starlark and removed incompatible-change Incompatible/breaking change team-Starlark labels Apr 4, 2019
bazel-io pushed a commit that referenced this issue Mar 24, 2020
#7950

RELNOTES: The flag `incompatible_no_output_attr_default` is removed.
PiperOrigin-RevId: 302635771
luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 4, 2022
    bazelbuild/bazel#7950

    RELNOTES: The flag `incompatible_no_output_attr_default` is removed.
    PiperOrigin-RevId: 302635771
luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 4, 2022
    Fixes bazelbuild/bazel#7950

    RELNOTES[INC]: `--incompatible_no_output_attr_default` is enabled by default.

    PiperOrigin-RevId: 243362752
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required)
Projects
None yet
Development

No branches or pull requests

2 participants