-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Motivation
Many rules (e.g. Python and Shell) that build an executable provide more than one file in their default outputs for technical reasons (e.g. symlinks to source files). This made it impossible to get the path to the executable via location expansion since $(execpath :x) will fail and $(execpaths :x) expands to multiple files, one of which is the executable.
In 457d248, this situation was improved by letting the singular forms of location expansion always prefer the executable if it would otherwise fail due to multiple files. While this by itself is a backwards compatible change, it wasn't possible to do this without also changing the behavior of the plural forms.
Description
$(locations :x) now expands to the executable of a target :x if it provides one and the number of files provided by it is not one. Previously, it would have expanded to the list of these files.
Incompatible Flag
--incompatible_locations_prefers_executable
Migration Guide
Usage of the plural forms should be rare, especially for executable rules. The native location expansion has always had this behavior, only the ongoing Starlarkification and increased usage of ctx.expand_location's extra target argument have made this change necessary. If needed, users can write a custom rule that accepts a rule and returns the space-separated list of output files via a custom Make variable.
In which Bazel LTS version will this incompatible change be enabled?
Bazel 9
Additional Context
No response
TODO List
No response