I was running a bazel deps
query with an output configured as --output label_kind
and found a ton of source file hits. Is there a mechanism for excluding source files from the results, some kind of inverse search retaining every kind but the source types? I'm imagining something perhaps like
bazel query "kind( ! source , deps(...))"
I did a quick value counts tabulation on the label_kinds
utilized in one application and found the bulk of the deps were just source files.
> bazel query "deps(//my_package/my_subpackage:my_target_app)" --output rankmin | awk '{print $1}' | sort | uniq -c | sort -nr
8634 source
20 cc_library
11 filegroup
3 config_setting
3 cc_binary
3 alias
1 sh_binary
1 py_binary
1 package
1 genrule
1 bind
There was actually a bunch of other custom in-house rules and what not so I can't do an explicit union of kinds since there may be additions to the repo that I'd have to keep up with.
It's a bit verbose, but you can do something like this (split on multiple lines for readability):
bazel query 'deps(//my_package/my_subpackage:my_target_app)
except kind("source file", deps(//my_package/my_subpackage:my_target_app))'
--output rankmin
The query functions deps()
and kind()
return sets of targets, so here we're pretty much subtracting from the full set of dependencies the set containing dependencies of type "source file".