Skip to content

incompatible_no_output_attr_default: Disable default parameter of output attributes #7950

@c-parsons

Description

@c-parsons

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
    )

Metadata

Metadata

Assignees

Labels

P1I'll work on this now. (Assignee required)incompatible-changeIncompatible/breaking change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions