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

Comments

Projects
None yet
2 participants
@c-parsons
Copy link
Contributor

commented Apr 4, 2019

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

@bazel-io bazel-io closed this in 774cf20 Apr 13, 2019

emusand added a commit to emusand/bazel that referenced this issue Apr 16, 2019

Enable --incompatible_no_output_attr_default by default
Fixes bazelbuild#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
You can’t perform that action at this time.