Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix constraint checking for OutputFileConfiguredTargets
When a rule creates additional labels using output-typed attributes, and then those output-file labels are used inside a select(), Bazel checks the restricted_to constraints for that dependency "statically", as if they weren't in a select at all. This leads to the confounding behavior that the following construct passes analysis fine: genrule( name = "foo", outs = ["foo.txt"], cmd = "echo foo > \"$@\"", restricted_to = [":a"], ) filegroup( name = "uses_foo", srcs = select({ ":some_condition": [":foo"], "//conditions:default": [], }), restricted_to = [":a", ":b"] ) But if the label in the srcs select is changed to ":foo.txt" (which is the exact same thing) bazel will error with ERROR: in filegroup rule //:uses_foo: dependency //:foo doesn't support expected environment: //:b Fix by moving the calculation of depLabelInSelect up above the point where the OutputFileConfiguredTarget is converted into the underlying ConfiguredTarget. Closes #21539. PiperOrigin-RevId: 612507761 Change-Id: Icc77bcf56729792268f1edac76a95dbffa72a4f5
- Loading branch information