Skip to content

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets

License

Notifications You must be signed in to change notification settings

rules-proto-grpc/rules_proto_grpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Protobuf and gRPC rules for Bazel

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets

If you or your company find these rules useful, please consider supporting the building and maintenance of these rules ☕

Important

The master branch now contains the Bzlmod-only update of the rules released in version 5.0.0. If you need to see the WORKSPACE based rules used in version 4.x.x, please see the legacy branch

Announcements 📣

2024/07/31 - Version 5.0.0

Version 5.0.0 has been released, which rewrites the rules to support Bzlmod only. Moving to Bzlmod provides a huge improvement in the stability and maintainability of these rules, as third-party transitive dependency management has been handed off to Bazel and new versions of gRPC and Protobuf should hopefully be able to be supported more rapidly.

At present not all languages supported by the 4.x.x are supported by this release, with support for the remaining languages being tracked here. For these unsupported languages - or for WORKSPACE repos - it is recommended you continue using the 4.x.x releases.

The way you use these rules is largely unchanged, but unfortunately the paths used for load of the rules will have changed due to the splitting into language-specific modules. Please see the docs for details of how to migrate your usage to these new rules, in particular the release notes.

2023/12/14 - Version 4.6.0

Version 4.6.0 has been released, which contains a few bug fixes for Bazel 7 support. Note that this is likely to be the last WORKSPACE supporting release of rules_proto_grpc, as new Bzlmod supporting rules are introduced in the next major version

2023/09/12 - Version 4.5.0

Version 4.5.0 has been released, which contains a number of version updates, bug fixes and usability improvements over 4.4.0. Additionally, the Rust rules contain a major change of underlying gRPC and Protobuf library; the rules now use Tonic and Prost respectively

Usage

Full documentation for the current and previous versions can be found here

Rules

Language Rule Description
Buf buf_proto_breaking_test Checks .proto files for breaking changes (example)
Buf buf_proto_lint_test Lints .proto files (example)
C c_proto_compile Generates C protobuf .h & .c files (example)
C c_proto_library Generates a C protobuf library using cc_library, with dependencies linked (example)
C cpp_proto_compile Generates C protobuf .h & .cc files (example)
C cpp_grpc_compile Generates C protobuf and gRPC .h & .cc files (example)
C cpp_proto_library Generates a C protobuf library using cc_library, with dependencies linked (example)
C cpp_grpc_library Generates a C protobuf and gRPC library using cc_library, with dependencies linked (example)
Documentation doc_docbook_compile Generates DocBook .xml documentation file (example)
Documentation doc_html_compile Generates .html documentation file (example)
Documentation doc_json_compile Generates .json documentation file (example)
Documentation doc_markdown_compile Generates Markdown .md documentation file (example)
Documentation doc_template_compile Generates documentation file using Go template file (example)
Go go_proto_compile Generates Go protobuf .go files (example)
Go go_grpc_compile Generates Go protobuf and gRPC .go files (example)
Go go_proto_library Generates a Go protobuf library using go_library from rules_go (example)
Go go_grpc_library Generates a Go protobuf and gRPC library using go_library from rules_go (example)
gRPC-Gateway gateway_grpc_compile Generates gRPC-Gateway .go files (example)
gRPC-Gateway gateway_openapiv2_compile Generates gRPC-Gateway OpenAPI v2 .json files (example)
gRPC-Gateway gateway_grpc_library Generates gRPC-Gateway library files (example)
Java java_proto_compile Generates a Java protobuf srcjar file (example)
Java java_grpc_compile Generates a Java protobuf and gRPC srcjar file (example)
Java java_proto_library Generates a Java protobuf library using java_library (example)
Java java_grpc_library Generates a Java protobuf and gRPC library using java_library (example)
Objective-C objc_proto_compile Generates Objective-C protobuf .m & .h files (example)
Objective-C objc_grpc_compile Generates Objective-C protobuf and gRPC .m & .h files (example)
Objective-C objc_proto_library Generates an Objective-C protobuf library using objc_library (example)
Objective-C objc_grpc_library Generates an Objective-C protobuf and gRPC library using objc_library (example)
Python python_proto_compile Generates Python protobuf .py files (example)
Python python_grpc_compile Generates Python protobuf and gRPC .py files (example)
Python python_grpclib_compile Generates Python protobuf and grpclib .py files (supports Python 3 only) (example)
Python python_proto_library Generates a Python protobuf library using py_library from rules_python (example)
Python python_grpc_library Generates a Python protobuf and gRPC library using py_library from rules_python (example)
Python python_grpclib_library Generates a Python protobuf and grpclib library using py_library from rules_python (supports Python 3 only) (example)

License

This project is derived from stackb/rules_proto under the Apache 2.0 license and this project therefore maintains the terms of that license