If I have
cc_binary(
name = "stooges",
srcs = [ "larry.cc", "curly.cc", "moe.cc" ],
)
Is there a Bazel query which will return "larry.cc", "curly.cc", "moe.cc" ?
At the moment the only thing I can think of is
$ bazel query --output=build //:stooges | perl -nwle 'print $1 if /srcs\s*=\s*\[([^]]*)\]/'
Get all labels listed in the
srcsattribute:In your case
bazel query 'labels(srcs,//:stooges)'.Should return:
If you want to have all
hdrsandsrcslabels:You can also make use of Bazel Aspects to query for source files. More details here.