Are Bazel proto rules usable for C++ and Java or are they not quite there yet? Do they support proto alone or is grpc also included? How do the rules actually work (genrule, action)?
(I know there are unofficial repos providing some of these rules but I'm particularly curious about the Bazel road map for protos).
Thanks!
You should be able to use cc_proto_library() -
1. Clone the google/protobuf repo (git clone https://github.com/google/protobuf.git)
2. "import" it into your Bazel workspace, by adding
local_repository(
name = "com_google_protobuf_cc",
path = "/path/to/protobuf/repo",
)
3. Build your favorite proto -
(in a BUILD file:)
proto_library(name = "favorite_proto", srcs = ["favorite.proto"])
cc_proto_library(name = "favorite_cc_proto", deps = [":favorite_proto"])
4. File bugs!
For this release, I tried the cc_proto_library rule, both with local and git repo rules but could not get it to work.
The first issue was that the latest protobuf release is too old and does not have a cc_toolchain rule defined in its BUILD file. To solve this, I cloned from head but ran into another issue: --direct_dependencies_violation_msg is not found by protoc. Reading https://github.com/google/protobuf/issues/2426, my guess is that the flag was not yet implemented.
Am I missing something here or is the cc_proto_library depending on some protobuf work that is not yet complete?
>>>> # //examples:bank_proto [action 'Generating Descriptor Set proto_library //examples:bank_proto']
(cd /home/dragos/.cache/bazel/_bazel_dragos/46c01e0b42c636fbf0a61595f67d333d/execroot/proto_test && \
exec env - \
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/mesa:/usr/lib/x86_64-linux-gnu/dri:/usr/lib/x86_64-linux-gnu/gallium-pipe \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games \
bazel-out/host/bin/third_party/protobuf/protoc '--descriptor_set_out=bazel-out/local-fastbuild/genfiles/examples/bank_proto-descriptor-set.proto.bin' '-Iexamples/bank.proto=examples/bank.proto' '--direct_dependencies=' '--direct_dependencies_violation_msg=%s is imported, but //examples:bank_proto doesn'\''t directly depend on a proto_library that '\''srcs'\'' it.' examples/bank.proto)
ERROR: /home/dragos/proto_test/examples/BUILD:1:1: Generating Descriptor Set proto_library //examples:bank_proto failed: linux-sandbox failed: error executing command /home/dragos/.cache/bazel/_bazel_dragos/46c01e0b42c636fbf0a61595f67d333d/execroot/proto_test/_bin/linux-sandbox ... (remaining 8 argument(s) skipped).
Unknown flag: --direct_dependencies_violation_msg
On Thursday, December 22, 2016 at 10:06:35 AM UTC-5, dione...@gmail.com wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "bazel-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-discuss/651R_0JvDLk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/409c4277-b33b-4b31-bb89-25503beb366d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/d9d2e72e-f319-4032-ae45-779ebb8cfa1a%40googlegroups.com.