Convertion from Label to Target within transition

Skip to first unread message

Kirill Zabelin

Jun 23, 2022, 8:47:49 AMJun 23
Hi everyone!

Documentation about attr.label has the following line about 'label' field -

At analysis time (within the rule's implementation function), when retrieving the attribute value from ctx.attr, labels are replaced by the corresponding Targets. This allows you to access the providers of the currrent target's dependencies.

Is it possible to somehow achieve the same effect within transition or repository_rule? Somehow convert Lable to Target?


Xudong Yang

Jun 23, 2022, 8:55:16 AMJun 23
to Kirill Zabelin, bazel-discuss
This is not possible in repository rules, because at the time repository rules are evaluated, analysis hasn't started yet. (Caveat: repo rule evaluation and analysis are technically interleaved but we don't allow you to "analyze" an arbitrary label in repo rules anyway, since that could result in cyclic dependencies.)

What are you trying to do?

You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Kirill Zabelin

Jun 24, 2022, 5:40:08 AMJun 24
to Xudong Yang, bazel-discuss
Ok, got it about the repository rule, thanks!

What about transition? As far as I know both transitions and rules are evaluated during the analysis stage.

Currently I am trying integrate kconfig with bazel. For this I want to make a transition take a look at output files of specific targets and based on output change configuration.

It seems that there is a TODO for something like this. I found this comment in ./src/main/java/com/google/devtools/build/lib/analysis/starlark/

 * <p>TODO(bazel-team): Consider allowing dependency-typed attributes to actually return providers
 * instead of just labels (see {@link StarlarkAttributesCollection#addAttribute}).


чт, 23 июн. 2022 г. в 15:55, Xudong Yang <>:
Reply all
Reply to author
0 new messages