Rules
- cc_proto_library
- java_lite_proto_library
- java_proto_library
- proto_library
- py_proto_library
- proto_lang_toolchain
- proto_toolchain
cc_proto_library
View rule sourceopen_in_newcc_proto_library generates C++ code from .proto files.
deps must point to proto_library rules.
Example:
Arguments
java_lite_proto_library
View rule sourceopen_in_newjava_lite_proto_library generates Java code from .proto files.
deps must point to proto_library rules.
Example:
Arguments
java_proto_library
View rule sourceopen_in_newjava_proto_library generates Java code from .proto files.
deps must point to proto_library rules.
Example:
Arguments
proto_library
View rule sourceopen_in_newproto_library to define libraries of protocol buffers which
may be used from multiple languages. A proto_library may be listed
in the deps clause of supported rules, such as
java_proto_library.
When compiled on the command-line, a proto_library creates a file
named foo-descriptor-set.proto.bin, which is the descriptor set for
the messages the rule srcs. The file is a serialized
FileDescriptorSet, which is described in
https://developers.google.com/protocol-buffers/docs/techniques#self-description.
It only contains information about the .proto files directly
mentioned by a proto_library rule; the collection of transitive
descriptor sets is available through the
[ProtoInfo].transitive_descriptor_sets Starlark provider.
See documentation in proto_info.bzl.
Recommended code organization:
- One
proto_libraryrule per.protofile.* A file namedfoo.protowill be in a rule namedfoo_proto, which is located in the same package.* A[language]_proto_librarythat wraps aproto_librarynamedfoo_protoshould be calledfoo_[language]_proto, and be located in the same package.
Arguments
py_proto_library
View rule sourceopen_in_newpy_proto_library to generate Python libraries from .proto files.
The convention is to name the py_proto_library rule foo_py_pb2,
when it is wrapping proto_library rule foo_proto.
deps must point to a proto_library rule.
Example:
Arguments
proto_lang_toolchain
View rule sourceopen_in_newjava_proto_library) should invoke the
proto-compiler.
Some LANG_proto_library rules allow specifying which toolchain to use using command-line flags;
consult their documentation.
Normally you should not write those kind of rules unless you want to
tune your Java compiler.
There’s no compiler. The proto-compiler is taken from the proto_library rule we attach to. It is
passed as a command-line flag to Blaze.
Several features require a proto-compiler to be invoked on the proto_library rule itself.
It’s beneficial to enforce the compiler that LANG_proto_library uses is the same as the one
proto_library does.