Reputation: 6187
I wanted to see all of my dependency graph for a bazel target, for that I can use below query
bazelisk query --notool_deps --noimplicit_deps "deps(//sample-target:sample-target)" --output graph
this will show me the dependency graph,
now I wanted to show more data on each node, for example if a node/target has attribute tags I wanted to show all tags there
is this possible?
Upvotes: 0
Views: 130
Reputation: 5006
Filtering by tag can be done with the attr()
function:
https://bazel.build/query/language#attr
But I don't think there's a direct way to print all the tags. A way around this is to use another output format like --output=streamed_jsonproto
which will include the attributes of the targets among other things.
For example:
genrule(
name = "gen",
outs = ["gen.txt"],
cmd = "touch $@",
tags = ["foo", "bar"],
)
bazel query --notool_deps --noimplicit_deps "gen" --output=streamed_jsonproto
will include:
{
"type": "RULE",
"rule": {
"name": "//:gen",
"ruleClass": "genrule",
"attribute": [
...
{
"name": "tags",
"type": "STRING_LIST",
"stringListValue": [
"bar",
"foo"
],
"explicitlySpecified": true,
"nodep": false
},
...
],
...
}
}
Or if you feel like getting into it, the code to generate the graph output is here and it might not be too difficult to have it add the tags to the node text:
Upvotes: 0