You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow ctx.expand_location to specify output_group #6001
When using ctx.expand_location() it would be great to be able to specify which output_group I want returned from the target.
Feature requests: what underlying problem are you trying to solve with this feature?
Sometime I want a specific (sub)set of the files returned from the target. Further right now just the implicit output of a target is taken, so it is not even possible to get some of the possible output from targets that may be requested by the rule.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Then another rule which has a target from this rule as dep, as well as an entry_point/main that specified a path to that dep (i.e. entry_point = "$(location :my_dep)") and then does:
ctx.expand_location(ctx.attr.entry_point)
This will get the implicit output specified by DefaultInfo even though I want to get the location of other_files
I think that's cleaner. I'm going to close the request.
The main use-case of expand_location was for reimplementing genrules (the users specifies the command in a BUILD file and wants to refer to other targets). In most other cases, I would suggest to avoid this function.
Activity
laurentlb commentedon Aug 28, 2018
Why do you use
ctx.expand_location()?Does the format string come from a BUILD file?
Globegitter commentedon Aug 29, 2018
Yes, to be more concrete I ran into that when working on this PR: bazel-contrib/rules_nodejs#217
The already existing
rollup_bundlerule expectsentry_pointto be passed in as a string.laurentlb commentedon Aug 29, 2018
For your example, can you use:
entry_point = ":test"?Then mark
entry_pointas a label, which will allow the rule to access any of its output groups.Globegitter commentedon Aug 29, 2018
Yeah I was thinking that as well as an alternative option, maybe that would indeed be the best way forward.
laurentlb commentedon Aug 29, 2018
I think that's cleaner. I'm going to close the request.
The main use-case of
expand_locationwas for reimplementing genrules (the users specifies the command in a BUILD file and wants to refer to other targets). In most other cases, I would suggest to avoid this function.Update documentation of expand_location
Update documentation of expand_location