33Bazel skylark rules for building [ protocol buffers] [ protobuf-home ]
44with +/- gRPC support on (osx, linux) :sparkles : .
55
6- [ bazel_image ] : https://github.com/pubref/rules_protobuf/blob/master/images/bazel.png
7- [ wtfcat_image ] : https://github.com/pubref/rules_protobuf/blob/master/images/wtfcat.png
8- [ grpc_image ] : https://github.com/pubref/rules_protobuf/blob/master/images/gRPC.png
9-
106<table border =" 0 " ><tr >
11- <td ><img src =" https://github.com/pubref/rules_protobuf/blob/master/ images/bazel.png " width = " 190 " /></td >
12- <td ><img src =" https://github.com/pubref/rules_protobuf/blob/master/images/wtfcat.png " width = " 190 " /></td >
13- <td ><img src =" https://github. com/pubref/rules_protobuf/blob/master/images/gRPC.png " width = " 190 " /></td >
7+ <td ><img src =" https://bazel.build/ images/bazel-icon.svg " height = " 180 " /></td >
8+ <td ><img src =" https://github.com/pubref/rules_protobuf/blob/master/images/wtfcat.png " height = " 180 " /></td >
9+ <td ><img src =" https://avatars2.githubusercontent. com/u/7802525?v=4&s=400 " height = " 180 " /></td >
1410</tr ><tr >
1511<td >Bazel</td >
1612<td >rules_protobuf</td >
1713<td >gRPC</td >
1814</tr ></table >
1915
20- ### How is this related to the proto\_ library rules within bazel
21- itself?
16+ ### How is this related to the proto\_ library rules within Bazel itself?
2217
2318These rules sprung out of a need to have protobuf support when there
2419was limited exposed and documented proto generation capabilities in
@@ -38,23 +33,27 @@ of this project are to:
3833 current and future custom protoc plugins not explicitly provided
3934 here.
4035
36+
4137### Rules
4238
43- | Language | Compile <sup >1</sup > | Build <sup >2</sup > | Protobuf | gRPC <sup >3</sup > |
39+ | Language | Compile <sup >1</sup > | Build <sup >2</sup > | gRPC <sup >3</sup > |
4440| ---------------------------: | -----------: | --------: | -------- |
45- | [ C++] ( cpp ) | [ cc_proto_compile] ( cpp#cc_proto_compile ) | [ cc_proto_library] ( cpp#cc_proto_library ) | [ v3.4.0] ( https://github.com/grpc/grpc/releases/tag/v1.6.1 ) | [ v1.6.1] ( https://github.com/grpc/grpc/releases/tag/v1.6.1 ) |
41+ | [ C++] ( cpp ) | [ cc_proto_compile] ( cpp#cc_proto_compile ) | [ cc_proto_library] ( cpp#cc_proto_library ) [ v3.4.0] ( https://github.com/grpc/grpc/releases/tag/v1.6.1 ) | [ v1.6.1] ( https://github.com/grpc/grpc/releases/tag/v1.6.1 ) |
4642| [ C#] ( csharp ) | [ csharp_proto_compile] ( csharp#csharp_proto_compile ) | [ csharp_proto_library] ( csharp#csharp_proto_library ) | [ 1.0.0] ( https://www.nuget.org/packages/Grpc/ ) |
4743| [ Closure] ( closure ) | [ closure_proto_compile] ( closure#closure_proto_compile ) | [ closure_proto_library] ( closure#closure_proto_library ) | |
4844| [ Go] ( go ) | [ go_proto_compile] ( go#go_proto_compile ) | [ go_proto_library] ( go#go_proto_library ) | [ v1.6.0] ( https://github.com/grpc/grpc-go/releases/tag/v1.6.0 ) |
4945| [ Go (gogo)] ( gogo ) | [ gogo_proto_compile] ( gogo#gogo_proto_compile ) | [ gogo_proto_library] ( gogo#gogo_proto_library ) | [ fb8a35] ( https://github.com/gogo/protobuf/commit/fb8a359905af6e2b6517cccda0ba25915322ee88 ) |
5046| [ gRPC gateway] ( grpc_gateway ) | [ grpc_gateway_proto_compile] ( grpc_gateway#grpc_gateway_proto_compile ) <br />[ grpc_gateway_swagger_compile] ( grpc_gateway#grpc_gateway_swagger_compile ) | [ grpc_gateway_proto_library] ( grpc_gateway#grpc_gateway_proto_library ) <br />[ grpc_gateway_binary] ( grpc_gateway#grpc_gateway_binary ) | [ v1.2.2+ (f2862b)] ( https://github.com/grpc-ecosystem/grpc-gateway/commit/f2862b476edcef83412c7af8687c9cd8e4097c0f ) |
5147| [ Java] ( java ) | [ java_proto_compile] ( java#java_proto_compile ) | [ java_proto_library] ( java#java_proto_library ) | [ v1.6.1] ( https://github.com/grpc/grpc-java/releases/tag/v1.6.1 ) |
5248| [ Node] ( node ) | [ node_proto_compile] ( js#node_proto_compile ) | [ node_proto_library] ( js#node_proto_library ) | [ 1.0.0] ( https://www.npmjs.com/package/grpc ) |
53- | [ Objective-C] ( objc ) | [ objc_proto_compile] ( objc#objc_proto_compile ) | [ objc_proto_library] ( objc#objc_proto_library ) <sup >4</sup > | [ v1.6.1< sup >673f</ sup > ] ( https://github.com/grpc/grpc/commit/f5600e99be0fdcada4b3039c0f656a305264884a ) |
54- | [ Python] ( python ) | [ py_proto_compile] ( python#py_proto_compile ) | | [ v1.6.1< sup >673f</ sup > ] ( https://github.com/grpc/grpc/commit/f5600e99be0fdcada4b3039c0f656a305264884a ) |
55- | [ Ruby] ( ruby ) | [ ruby_proto_compile] ( ruby#ruby_proto_compile ) | | [ v1.6.1< sup >673f</ sup > ] ( https://github.com/grpc/grpc/commit/f5600e99be0fdcada4b3039c0f656a305264884a ) |
49+ | [ Objective-C] ( objc ) | [ objc_proto_compile] ( objc#objc_proto_compile ) | [ objc_proto_library] ( objc#objc_proto_library ) <sup >4</sup > | [ v1.6.1] ( https://github.com/grpc/grpc/commit/f5600e99be0fdcada4b3039c0f656a305264884a ) |
50+ | [ Python] ( python ) | [ py_proto_compile] ( python#py_proto_compile ) | | [ v1.6.1] ( https://github.com/grpc/grpc/commit/f5600e99be0fdcada4b3039c0f656a305264884a ) |
51+ | [ Ruby] ( ruby ) | [ ruby_proto_compile] ( ruby#ruby_proto_compile ) | | [ v1.6.1] ( https://github.com/grpc/grpc/commit/f5600e99be0fdcada4b3039c0f656a305264884a ) |
5652| Custom [ proto_language] ( protobuf#proto_language ) | [ proto_compile] ( protobuf#proto_compile ) | | |
5753
54+ > Refer to [ ` DEPENDENCIES.md ` ] ( DEPENDENCIES.md ) for a more detailed
55+ > summary of workspace dependencies / versions.
56+
58571 . Support for generation of protoc outputs via ` proto_compile() `
5958 rule.
6059
@@ -71,13 +70,12 @@ of this project are to:
7170
7271## 1. Install Bazel
7372
74- These are build rules for [ bazel] [ bazel-home ] . If you have not
75- already installed ` bazel ` on your workstation, follow the
76- [ bazel instructions] [ bazel-install ] .
73+ If you have not already installed ` bazel ` on your workstation, follow
74+ the [ bazel instructions] [ bazel-install ] .
7775
7876** Bazel 0.5.2 or above is required for go support. Bazel 0.5.3 is
79- [ incompatible] ( https://github.com/bazelbuild/bazel/issues/3622 ) , but
80- 0.5.4 should work.**
77+ [ incompatible] ( https://github.com/bazelbuild/bazel/issues/3622 ) ( but
78+ 0.5.4 should work) .**
8179
8280> Note about protoc and related tools: bazel and rules_protobuf will
8381> download or build-from-source all required dependencies, including
@@ -120,16 +118,6 @@ to load before the `*_proto_repositories()` function is invoked:
120118| csharp_proto_repositories | [ rules_dotnet] ( https://github.com/bazelbuild/rules_dotnet ) |
121119| node_proto_repositories | [ rules_node] ( https://github.com/pubref/rules_node ) |
122120
123- If you're only interested in the ` proto_compile ` rule and not any
124- language-specific rules, just load the generic ` proto_repositories `
125- rule. This provides the minimal set of dependencies (only the
126- ` protoc ` tool).
127-
128- ``` python
129- load(" @org_pubref_rules_protobuf//protobuf:rules.bzl" , " proto_repositories" )
130- proto_repositories()
131- ```
132-
133121## 3. Add \*\_ proto\_\* rules to your BUILD files
134122
135123To build a java-based gRPC library:
@@ -188,7 +176,8 @@ load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_repositories")
188176go_proto_repositories(
189177 overrides = {
190178 " com_github_golang_protobuf" : {
191- " commit" : " 2c1988e8c18d14b142c0b472624f71647cf39adb" , # Aug 8, 2016
179+ # Override golang with a different commit
180+ " commit" : " 2c1988e8c18d14b142c0b472624f71647cf39adb" ,
192181 }
193182 },
194183)
@@ -291,17 +280,17 @@ java_proto_library(
291280 name = ' fooprotos' ,
292281 protos = ' foo.proto`,
293282 imports = [
294- " external/com_github_google_protobuf /src/" ,
283+ " external/com_google_protobuf /src/" ,
295284 ],
296285 inputs = [
297- " @com_github_google_protobuf //:well_known_protos" ,
286+ " @com_google_protobuf //:well_known_protos" ,
298287 ],
299288)
300289```
301290
302291This would be imported as ` import "google/protobuf/descriptor.proto" `
303292given that the file
304- ` @com_github_google_protobuf /src/google/protobuf/descriptor.proto ` is
293+ ` @com_google_protobuf /src/google/protobuf/descriptor.proto ` is
305294in the package ` google.protobuf ` .
306295
307296[ Question 2] : * Can the ` cc_proto_library ` rule "see" the generated protobuf files* ?
@@ -328,18 +317,15 @@ attribute, just as you would any typical `cc_library` rule.
328317If you are having problems, put ` verbose={1,2,3} ` in your build rule
329318and/or disable sandboxing with ` --spawn_strategy=standalone ` .
330319
331- > Note: bazel will likely a breaking change to the way external
332- > repositories are laid out in the execution root in future versions
333- > of bazel. This will likely affect the naming of import paths when
334- > this change occurs.
335-
336320# Contributing
337321
338322Contributions welcome; please create Issues or GitHub pull requests.
339323
340324# Credits
341325
342- * Much thanks to all [ contributors] ( https://github.com/pubref/rules_protobuf/graphs/contributors ) and the members of the bazel, protobuf, and gRPC teams.
326+ * Much thanks to all
327+ [ contributors] ( https://github.com/pubref/rules_protobuf/graphs/contributors )
328+ and the members of the bazel, protobuf, and gRPC teams.
343329
344330[ protobuf-home ] : https://developers.google.com/protocol-buffers/ " Protocol Buffers Developer Documentation "
345331[ bazel-home ] : http://bazel.io " Bazel Homepage "
@@ -348,13 +334,4 @@ Contributions welcome; please create Issues or GitHub pull requests.
348334[ rules_go ] : http://github.com/bazelbuild/rules_go " Rules Go "
349335[ grpc-gateway-home ] :https://github.com/grpc-ecosystem/grpc-gateway
350336
351- [ bazel_image ] : https://github.com/pubref/rules_protobuf/blob/master/images/bazel.png
352- [ wtfcat_image ] : https://github.com/pubref/rules_protobuf/blob/master/images/wtfcat.png
353- [ grpc_image ] : https://github.com/pubref/rules_protobuf/blob/master/images/gRPC.png
354-
355- [ repositories.bzl ] : protobuf/internal/repositories.bzl
356-
357337[ skylark-dict ] : https://www.bazel.io/docs/skylark/lib/dict.html " Skylark Documentation for dict "
358- [ skylark-string ] : https://www.bazel.io/docs/skylark/lib/attr.html#string " Skylark string attribute "
359- [ skylark-string_list ] : https://www.bazel.io/docs/skylark/lib/attr.html#string_list " Skylark string_list attribute "
360- [ skylark-string_list_dict ] : https://www.bazel.io/docs/skylark/lib/attr.html#string_list_dict " Skylark string_list_dict attribute "
0 commit comments