Skip to content

Conversation

mattnworb
Copy link

We have what is probably an unconventional style in some of our BUILD files where a macro is used to define several targets and returns a struct of some information so that things like labels of generated targets can be passed as attributes to other targets in the same BUILD file, without the BUILD file needing to hardcode or be aware of the naming convention of the macro's internals.

buildozer and unused_deps are unable to operate on targets in AssignExpr statements since edit.FindRuleByName() and edit.IndexOfRuleByName() skip over any nodes that are not call expressions. This commit adapts these functions to be able to find call expressions that are on the right-hand side of an assignment expression.

fixes #1306

We have what is probably an unconventional style in some of our BUILD
files where a macro is used to define several targets and returns a
struct of some information so that things like labels of generated
targets can be passed as attributes to other targets in the same
BUILD file, without the BUILD file needing to hardcode or be aware of
the naming convention of the macro's internals.

buildozer and unused_deps are unable to operate on targets in
`AssignExpr` statements since `edit.FindRuleByName()` and
`edit.IndexOfRuleByName()` skip over any nodes that are not call
expressions. This commit adapts these functions to be able to find call
expressions that are on the right-hand side of an assignment expression.

fixes bazelbuild#1306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

buildozer fails to find targets that are macros with a return value assigned to a variable
1 participant