bazel icon indicating copy to clipboard operation
bazel copied to clipboard

proto_library build rules

Open davidzchen opened this issue 11 years ago • 31 comments

The Build Encyclopedia documentation for objc_proto_library references proto_library, which does not seem to have been open sourced yet.

On the same note, objc_proto_library seems to be the only available rule for building proto libraries. What is the plan for proto_library rules for other languages?

davidzchen avatar Mar 25 '15 10:03 davidzchen

We're not yet ready to open-source the more generic proto_library rule. In the meantime you can use genproto, see https://github.com/google/bazel/blob/master/src/main/protobuf/BUILD, or write a genrule. I'll remove the reference from the BE for now.

laszlocsomor avatar Mar 25 '15 10:03 laszlocsomor

(sorry, shouldn't have closed this just yet)

laszlocsomor avatar Mar 25 '15 11:03 laszlocsomor

Is there a timeline for releasing proto_library support? We'd love to ditch Kythe's campfire build system, but can't feasibly do so without proto_library.

collinw avatar Apr 02 '15 23:04 collinw

For now we have a genproto that supports Java using Skylark (see tools/build_rules/genproto.bzl and its usage in the link Laszlo sent. You can easily adapt it for other languages.

On Fri, Apr 3, 2015 at 1:57 AM Collin Winter [email protected] wrote:

Is there a timeline for releasing proto_library support? We'd love to ditch Kythe's campfire build system, but can't feasibly do so without proto_library.

— Reply to this email directly or view it on GitHub https://github.com/google/bazel/issues/52#issuecomment-89084720.

damienmg avatar Apr 03 '15 09:04 damienmg

The Kythe team has found that the genproto rule isn't as easy to use as you've suggested. It seems to have at least one severe issue that we'd need fixed before we migrate to using Bazel.

Bazel special-cases the genproto Skylark rule for Java (see BazelJavaRuleClasses.java). It does not, however, support the native C++ rules in the same way. We have thought of a few ways to workaround this problem but feel that they would burden us in the same way as having our own build system. Switching to Bazel (from Campfire) is meant to remove these types of concerns from our team.

Likewise, having to write our own support for C++ (and Go) means maintaining even more build-related logic. It would be nice if C++ was supported in genproto by the Bazel team. That would minimize our need for forking/maintaining the existing rule.

Other Relevant C++ issues:

  • https://github.com/google/bazel/issues/114
  • https://github.com/google/bazel/issues/117

schroederc avatar Apr 13 '15 17:04 schroederc

You should be able to write a genproto rule that generate .c or .cc files and put that into cc_library.srcs. If you want to make it look like what we have internally, you can wrap that in a Skylark macro.

We're working on proto_library as well as go support this quarter. It's unlikely that we'll explicitly support something else before that is ready. If we were in a hurry, go support could be ready in ~weeks, but proper proto_library support is tricky.

On Mon, Apr 13, 2015 at 7:06 PM, Cody Schroeder [email protected] wrote:

The Kythe team has found that the genproto rule isn't as easy to use as you've suggested. It seems to have at least one severe issue that we'd need fixed before we migrate to using Bazel.

Bazel special-cases the genproto Skylark rule for Java (see BazelJavaRuleClasses.java https://github.com/google/bazel/blob/master/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java#L118). It does not, however, support the native C++ rules in the same way. We have thought of a few ways to workaround this problem but feel that they would burden us in the same way as having our own build system. Switching to Bazel (from Campfire) is meant to remove these types of concerns from our team.

Likewise, having to write our own support for C++ (and Go) means maintaining even more build-related logic. It would be nice if C++ was supported in genproto by the Bazel team. That would minimize our need for forking/maintaining the existing rule.

Other Relevant C++ issues:

  • #114 https://github.com/google/bazel/issues/114
  • #117 https://github.com/google/bazel/issues/117

— Reply to this email directly or view it on GitHub https://github.com/google/bazel/issues/52#issuecomment-92426443.

ulfbot avatar Apr 14 '15 07:04 ulfbot

I have a simple macro that creates genrule and cc_library targets for proto files, just FYI: https://github.com/mzhaom/trunk/blob/master/third_party/grpc/grpc_proto.bzl

mzhaom avatar Apr 14 '15 15:04 mzhaom

A quick status update: this is something we working on shiping but it will take a long time

damienmg avatar Jun 19 '15 12:06 damienmg

Any ETA on this? We're using protos in Shipshape and would love to use standard rules.

clconway avatar Oct 05 '15 23:10 clconway

Not yet. We are thinking of shipping it by the end of the year but it is not yet decided. You are pinging at the good moment :)

On Tue, Oct 6, 2015, 1:53 AM clconway [email protected] wrote:

Any ETA on this? We're using protos in Shipshape https://github.com/google/shipshape/blob/master/shipshape/proto and would love to use standard rules.

— Reply to this email directly or view it on GitHub https://github.com/bazelbuild/bazel/issues/52#issuecomment-145700737.

damienmg avatar Oct 06 '15 06:10 damienmg

It should happens this quarter

damienmg avatar Oct 09 '15 14:10 damienmg

Will this support Go when it ships?

perezd avatar Nov 13 '15 00:11 perezd

Yes. It will support both Skylark and native rules.

damienmg avatar Nov 13 '15 09:11 damienmg

Hi! Is there any status update? Thanks

arslan-urtashev avatar Mar 09 '16 11:03 arslan-urtashev

I think we are moving to making the rules provided by google/protobuf good one instead of shipping our legacy support. No ETA.

damienmg avatar Mar 09 '16 15:03 damienmg

Any status update on this?

kqyang avatar Jul 14 '16 23:07 kqyang

What is the current guidance for generating Java from proto files?

robfig avatar Jul 31 '16 21:07 robfig

@robfig I just released https://github.com/pubref/rules_protobuf/tree/0.1.1 for my own use but hopefully it's useful for you.

pcj avatar Aug 01 '16 01:08 pcj

@pcj I love your graphical explanation of that repo :D

jcanizales avatar Aug 01 '16 18:08 jcanizales

It seems that proto_library now exists here: http://bazel.io/docs/be/protocol-buffer.html However, it a) needs the protobuf library to be in third_party/protobuf, and I can't seem to get it working with cc_library. Has anyone used the builtin proto_library with c++?

thesamwise avatar Aug 25 '16 04:08 thesamwise