Reputation: 7087
I want to get mutual dependencies of all dependencies of a target, to provide this information to a binary (for static analysis).
I defined a rule that loop through direct dependencies. How can I get dependencies of each dependency, to discover the entire graph recursively? Is it possible at all? If no, is there an alternative way?
def _impl(ctx):
for i, d in enumerate(ctx.attr.deps):
# I need to get dependencies of d somehow here
Upvotes: 0
Views: 2623
Reputation: 7087
I need to pass parameter --output=graph to genquery
:
blaze query "kind(rule, deps(//path/to/mytarget))" --output=graph
Upvotes: 0
Reputation: 5016
Depending on exactly what information you want, Aspects may do what you want: https://docs.bazel.build/versions/master/skylark/aspects.html
They allow a rule to collect additional information from transitive dependencies.
There's also the genquery
rule, but this may or may not give you all the information you want: https://docs.bazel.build/versions/master/be/general.html#genquery
genquery
makes bazel query results available to actions.
Upvotes: 2