bazel query for sources includes proto target

536 views
Skip to first unread message

brice.r...@gmail.com

unread,
Feb 22, 2016, 7:40:12 PM2/22/16
to bazel-discuss
I'm querying for the list of c++ sources in my project, to build the project description for my IDE (QtCreator). I'm using the following query:

bazel query 'labels(srcs, kind("cc_.* rule", ...)) union labels(hdrs, kind("cc_.* rule", ...))'

unfortunately it also returns the protobuf "target", such as:
//vehicle/common/roads:rn2_proto
for file
vehicle/common/roads/rn2.proto

Is my query wrong? Or is it a bug in bazel query? Or is it the proto rule that list the wrong item in its srcs field?

Alex Humesky

unread,
Feb 22, 2016, 8:04:43 PM2/22/16
to brice.r...@gmail.com, bazel-discuss
It's probably better to put the protos in the deps attribute. I'm a little surprised bazel didn't complain about the proto being in the srcs attr. Which proto rules are you using?

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/7eb98db7-2cb4-4390-a701-8a14557f91ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brice Rebsamen

unread,
Feb 22, 2016, 8:48:33 PM2/22/16
to Alex Humesky, bazel-discuss
seems like one of my colleagues cobbled the rule together from some reference... Is there a standard protobuf bazel rule that one should use?

Alex Humesky

unread,
Feb 22, 2016, 9:07:29 PM2/22/16
to Brice Rebsamen, bazel-discuss
Ah, I see, then it could be doing anything.
It's probably generating cc files from the protocol buffer compiler, so those cc files will need to go into a cc_library at some point.
Bazel query can be kind of a fiddly thing. You might try using the "source file" and "generated file" patterns for kind. For example, if you have a single cc_binary that everything goes into, you could try 'kind("source file", //my/package/my_cc_binary) union kind("generated file", //my/package/my_cc_binary)'


There's cc_proto_library here from the protobuf library itself: https://github.com/google/protobuf/blob/master/protobuf.bzl
I've never used it though.
Reply all
Reply to author
Forward
0 new messages