AnalysisResult
The result of running an analysis in bxl.
AnalysisResult.as_dependency
def AnalysisResult.as_dependency(
) -> Dependency
Converts the analysis result into a Dependency. Currently, you can only get a Dependency without any transitions. This means that you cannot create an exec dep or toolchain from an analysis result.
We may support other dependency transition types in the future.
This is useful for passing in the results of ctx.analysis() into anon targets.
Sample usage:
def _impl_dependency(ctx):
node = ctx.configured_targets("root//bin:the_binary")
dependency = ctx.analysis(node).as_dependency()
AnalysisResult.providers
def AnalysisResult.providers(
) -> ProviderCollection
Access the providers of the rule. Returns a ProviderCollection the same as accessing providers of dependencies within a rule implementation.
Sample usage:
def _impl_providers(ctx):
node = ctx.configured_targets("root//bin:the_binary")
providers = ctx.analysis(node).providers()
ctx.output.print(providers[FooInfo])
providers = ctx.analysis("//:bin").providers()
ctx.output.print(providers[FooInfo])
AnalysisResult.providers_info
def AnalysisResult.providers_info()
Returns a list of structs describing each provider in the collection. Each struct has three fields: - name: The provider type name (e.g., "DefaultInfo", "FooInfo") - path: The cell path of the .bzl file where the provider was defined (e.g., "fbcode//pkg/defs.bzl"), or None for built-in providers - value: The provider instance itself
This enables BXL scripts to enumerate all providers on a target without knowing the provider types in advance.
Sample usage:
def _impl_providers_info(ctx):
node = ctx.configured_targets("root//bin:the_binary")
result = ctx.analysis(node)
for info in result.providers_info():
ctx.output.print(info.name)
ctx.output.print(info.path)
ctx.output.print(info.value)