protocol buffers - bazel rules for the protobuf C++ compiler -
i'm using bazel , google's protocol buffers. want add bazel rule can generate c++ api .proto
files. in gnu make, (simplified example):
%.h: %.cc %.cc: %.proto protoc --cpp_out=. $<
how can accomplish same (i.e. generate api whenever mymessage.proto
changes) using bazel?
native support cc_proto_library
has landed in bazel: http://bazel.build/blog/2017/02/27/protocol-buffers.html.
tl;dr, after setting workspace
file once,
cc_proto_library( name = "person_cc_proto", deps = [":person_proto"], ) proto_library( name = "person_proto", srcs = ["person.proto"], deps = [":address_proto"], ) ...
then,
$ bazel build :person_cc_proto
there's example @ https://github.com/cgrushko/proto_library.
the gist define proto_library
"import" .proto file bazel, , cc_proto_library
compile c++. protocol buffer compiler , runtimes taken default @com_google_protobuf//:protoc
, @com_google_protobuf_cc//:cc_toolchain
, respectively.
the reason separation enable large proto graphs need compiled multiple languages.
Comments
Post a Comment