Move grpc-web rules into //js

This commit is contained in:
Adam Liddell 2021-02-18 22:19:02 +00:00
parent cd2a6ec575
commit ba3d5705b5
53 changed files with 461 additions and 1202 deletions

View File

@ -12,7 +12,6 @@ tasks:
- "//d/..."
- "//go/..."
- "//grpc-gateway/..."
- "//grpc-web/..."
- "//java/..."
- "//js/..."
- "//php/..."
@ -110,7 +109,6 @@ tasks:
- "//d/..."
- "//go/..."
- "//grpc-gateway/..."
- "//grpc-web/..."
- "//java/..."
- "//js/..."
- "//objc/..."
@ -599,106 +597,6 @@ tasks:
build_targets:
- "//..."
working_directory: example/grpc-gateway/gateway_grpc_library
grpc-web_closure_grpc_compile_ubuntu1804:
name: 'grpc-web: closure_grpc_compile'
platform: ubuntu1804
build_targets:
- "//..."
working_directory: example/grpc-web/closure_grpc_compile
grpc-web_closure_grpc_compile_windows:
name: 'grpc-web: closure_grpc_compile'
platform: windows
build_targets:
- "//..."
working_directory: example/grpc-web/closure_grpc_compile
grpc-web_closure_grpc_compile_macos:
name: 'grpc-web: closure_grpc_compile'
platform: macos
build_flags:
- "--copt=-DGRPC_BAZEL_BUILD"
build_targets:
- "//..."
working_directory: example/grpc-web/closure_grpc_compile
grpc-web_commonjs_grpc_compile_ubuntu1804:
name: 'grpc-web: commonjs_grpc_compile'
platform: ubuntu1804
build_targets:
- "//..."
working_directory: example/grpc-web/commonjs_grpc_compile
grpc-web_commonjs_grpc_compile_windows:
name: 'grpc-web: commonjs_grpc_compile'
platform: windows
build_targets:
- "//..."
working_directory: example/grpc-web/commonjs_grpc_compile
grpc-web_commonjs_grpc_compile_macos:
name: 'grpc-web: commonjs_grpc_compile'
platform: macos
build_flags:
- "--copt=-DGRPC_BAZEL_BUILD"
build_targets:
- "//..."
working_directory: example/grpc-web/commonjs_grpc_compile
grpc-web_commonjs_dts_grpc_compile_ubuntu1804:
name: 'grpc-web: commonjs_dts_grpc_compile'
platform: ubuntu1804
build_targets:
- "//..."
working_directory: example/grpc-web/commonjs_dts_grpc_compile
grpc-web_commonjs_dts_grpc_compile_windows:
name: 'grpc-web: commonjs_dts_grpc_compile'
platform: windows
build_targets:
- "//..."
working_directory: example/grpc-web/commonjs_dts_grpc_compile
grpc-web_commonjs_dts_grpc_compile_macos:
name: 'grpc-web: commonjs_dts_grpc_compile'
platform: macos
build_flags:
- "--copt=-DGRPC_BAZEL_BUILD"
build_targets:
- "//..."
working_directory: example/grpc-web/commonjs_dts_grpc_compile
grpc-web_ts_grpc_compile_ubuntu1804:
name: 'grpc-web: ts_grpc_compile'
platform: ubuntu1804
build_targets:
- "//..."
working_directory: example/grpc-web/ts_grpc_compile
grpc-web_ts_grpc_compile_windows:
name: 'grpc-web: ts_grpc_compile'
platform: windows
build_targets:
- "//..."
working_directory: example/grpc-web/ts_grpc_compile
grpc-web_ts_grpc_compile_macos:
name: 'grpc-web: ts_grpc_compile'
platform: macos
build_flags:
- "--copt=-DGRPC_BAZEL_BUILD"
build_targets:
- "//..."
working_directory: example/grpc-web/ts_grpc_compile
grpc-web_closure_grpc_library_ubuntu1804:
name: 'grpc-web: closure_grpc_library'
platform: ubuntu1804
build_targets:
- "//..."
working_directory: example/grpc-web/closure_grpc_library
grpc-web_closure_grpc_library_windows:
name: 'grpc-web: closure_grpc_library'
platform: windows
build_targets:
- "//..."
working_directory: example/grpc-web/closure_grpc_library
grpc-web_closure_grpc_library_macos:
name: 'grpc-web: closure_grpc_library'
platform: macos
build_flags:
- "--copt=-DGRPC_BAZEL_BUILD"
build_targets:
- "//..."
working_directory: example/grpc-web/closure_grpc_library
java_java_proto_compile_ubuntu1804:
name: 'java: java_proto_compile'
platform: ubuntu1804
@ -799,26 +697,46 @@ tasks:
build_targets:
- "//..."
working_directory: example/js/js_proto_compile
js_nodejs_grpc_compile_ubuntu1804:
name: 'js: nodejs_grpc_compile'
js_js_grpc_node_compile_ubuntu1804:
name: 'js: js_grpc_node_compile'
platform: ubuntu1804
build_targets:
- "//..."
working_directory: example/js/nodejs_grpc_compile
js_nodejs_grpc_compile_windows:
name: 'js: nodejs_grpc_compile'
working_directory: example/js/js_grpc_node_compile
js_js_grpc_node_compile_windows:
name: 'js: js_grpc_node_compile'
platform: windows
build_targets:
- "//..."
working_directory: example/js/nodejs_grpc_compile
js_nodejs_grpc_compile_macos:
name: 'js: nodejs_grpc_compile'
working_directory: example/js/js_grpc_node_compile
js_js_grpc_node_compile_macos:
name: 'js: js_grpc_node_compile'
platform: macos
build_flags:
- "--copt=-DGRPC_BAZEL_BUILD"
build_targets:
- "//..."
working_directory: example/js/nodejs_grpc_compile
working_directory: example/js/js_grpc_node_compile
js_js_grpc_web_compile_ubuntu1804:
name: 'js: js_grpc_web_compile'
platform: ubuntu1804
build_targets:
- "//..."
working_directory: example/js/js_grpc_web_compile
js_js_grpc_web_compile_windows:
name: 'js: js_grpc_web_compile'
platform: windows
build_targets:
- "//..."
working_directory: example/js/js_grpc_web_compile
js_js_grpc_web_compile_macos:
name: 'js: js_grpc_web_compile'
platform: macos
build_flags:
- "--copt=-DGRPC_BAZEL_BUILD"
build_targets:
- "//..."
working_directory: example/js/js_grpc_web_compile
js_js_proto_library_ubuntu1804:
name: 'js: js_proto_library'
platform: ubuntu1804
@ -839,26 +757,46 @@ tasks:
build_targets:
- "//..."
working_directory: example/js/js_proto_library
js_nodejs_grpc_library_ubuntu1804:
name: 'js: nodejs_grpc_library'
js_js_grpc_node_library_ubuntu1804:
name: 'js: js_grpc_node_library'
platform: ubuntu1804
build_targets:
- "//..."
working_directory: example/js/nodejs_grpc_library
js_nodejs_grpc_library_windows:
name: 'js: nodejs_grpc_library'
working_directory: example/js/js_grpc_node_library
js_js_grpc_node_library_windows:
name: 'js: js_grpc_node_library'
platform: windows
build_targets:
- "//..."
working_directory: example/js/nodejs_grpc_library
js_nodejs_grpc_library_macos:
name: 'js: nodejs_grpc_library'
working_directory: example/js/js_grpc_node_library
js_js_grpc_node_library_macos:
name: 'js: js_grpc_node_library'
platform: macos
build_flags:
- "--copt=-DGRPC_BAZEL_BUILD"
build_targets:
- "//..."
working_directory: example/js/nodejs_grpc_library
working_directory: example/js/js_grpc_node_library
js_js_grpc_web_library_ubuntu1804:
name: 'js: js_grpc_web_library'
platform: ubuntu1804
build_targets:
- "//..."
working_directory: example/js/js_grpc_web_library
js_js_grpc_web_library_windows:
name: 'js: js_grpc_web_library'
platform: windows
build_targets:
- "//..."
working_directory: example/js/js_grpc_web_library
js_js_grpc_web_library_macos:
name: 'js: js_grpc_web_library'
platform: macos
build_flags:
- "--copt=-DGRPC_BAZEL_BUILD"
build_targets:
- "//..."
working_directory: example/js/js_grpc_web_library
objc_objc_proto_compile_macos:
name: 'objc: objc_proto_compile'
platform: macos

View File

@ -35,7 +35,6 @@
- [D](/d/README.md)
- [Go](/go/README.md)
- [grpc-gateway](/grpc-gateway/README.md)
- [gRPC-Web](/grpc-web/README.md)
- [Java](/java/README.md)
- [JavaScript](/js/README.md)
- [Objective-C](/objc/README.md)
@ -155,19 +154,16 @@ required.
| [grpc-gateway](/grpc-gateway) | [gateway_grpc_compile](/grpc-gateway#gateway_grpc_compile) | Generates grpc-gateway `.go` files ([example](/example/grpc-gateway/gateway_grpc_compile)) |
| [grpc-gateway](/grpc-gateway) | [gateway_openapiv2_compile](/grpc-gateway#gateway_openapiv2_compile) | Generates grpc-gateway OpenAPI v2 `.json` files ([example](/example/grpc-gateway/gateway_openapiv2_compile)) |
| [grpc-gateway](/grpc-gateway) | [gateway_grpc_library](/grpc-gateway#gateway_grpc_library) | Generates grpc-gateway library files ([example](/example/grpc-gateway/gateway_grpc_library)) |
| [gRPC-Web](/grpc-web) | [closure_grpc_compile](/grpc-web#closure_grpc_compile) | Generates Closure *.js protobuf+gRPC files ([example](/example/grpc-web/closure_grpc_compile)) |
| [gRPC-Web](/grpc-web) | [commonjs_grpc_compile](/grpc-web#commonjs_grpc_compile) | Generates CommonJS *.js protobuf+gRPC files ([example](/example/grpc-web/commonjs_grpc_compile)) |
| [gRPC-Web](/grpc-web) | [commonjs_dts_grpc_compile](/grpc-web#commonjs_dts_grpc_compile) | Generates commonjs_dts *.js protobuf+gRPC files ([example](/example/grpc-web/commonjs_dts_grpc_compile)) |
| [gRPC-Web](/grpc-web) | [ts_grpc_compile](/grpc-web#ts_grpc_compile) | Generates CommonJS *.ts protobuf+gRPC files ([example](/example/grpc-web/ts_grpc_compile)) |
| [gRPC-Web](/grpc-web) | [closure_grpc_library](/grpc-web#closure_grpc_library) | Generates protobuf closure library *.js files ([example](/example/grpc-web/closure_grpc_library)) |
| [Java](/java) | [java_proto_compile](/java#java_proto_compile) | Generates a Java protobuf srcjar artifact ([example](/example/java/java_proto_compile)) |
| [Java](/java) | [java_grpc_compile](/java#java_grpc_compile) | Generates a Java protobuf+gRPC srcjar artifact ([example](/example/java/java_grpc_compile)) |
| [Java](/java) | [java_proto_library](/java#java_proto_library) | Generates a Java protobuf library using `java_library` ([example](/example/java/java_proto_library)) |
| [Java](/java) | [java_grpc_library](/java#java_grpc_library) | Generates a Java protobuf+gRPC library using `java_library` ([example](/example/java/java_grpc_library)) |
| [JavaScript](/js) | [js_proto_compile](/js#js_proto_compile) | Generates JavaScript protobuf `.js` and `.d.ts` artifacts ([example](/example/js/js_proto_compile)) |
| [JavaScript](/js) | [nodejs_grpc_compile](/js#nodejs_grpc_compile) | Generates JavaScript protobuf + Node.js gRPC `.js` and `.d.ts` artifacts ([example](/example/js/nodejs_grpc_compile)) |
| [JavaScript](/js) | [js_grpc_node_compile](/js#js_grpc_node_compile) | Generates JavaScript protobuf + gRPC-node `.js` and `.d.ts` artifacts ([example](/example/js/js_grpc_node_compile)) |
| [JavaScript](/js) | [js_grpc_web_compile](/js#js_grpc_web_compile) | Generates JavaScript protobuf + gRPC-Web `.js` and `.d.ts` artifacts ([example](/example/js/js_grpc_web_compile)) |
| [JavaScript](/js) | [js_proto_library](/js#js_proto_library) | Generates a JavaScript protobuf library using `js_library` from `rules_nodejs` ([example](/example/js/js_proto_library)) |
| [JavaScript](/js) | [nodejs_grpc_library](/js#nodejs_grpc_library) | Generates a Node.js protobuf+gRPC library using `js_library` from `rules_nodejs` ([example](/example/js/nodejs_grpc_library)) |
| [JavaScript](/js) | [js_grpc_node_library](/js#js_grpc_node_library) | Generates a Node.js protobuf + gRPC-node library using `js_library` from `rules_nodejs` ([example](/example/js/js_grpc_node_library)) |
| [JavaScript](/js) | [js_grpc_web_library](/js#js_grpc_web_library) | Generates a JavaScript protobuf + gRPC-Web library using `js_library` from `rules_nodejs` ([example](/example/js/js_grpc_web_library)) |
| [Objective-C](/objc) | [objc_proto_compile](/objc#objc_proto_compile) | Generates Objective-C protobuf `.m` & `.h` artifacts ([example](/example/objc/objc_proto_compile)) |
| [Objective-C](/objc) | [objc_grpc_compile](/objc#objc_grpc_compile) | Generates Objective-C protobuf+gRPC `.m` & `.h` artifacts ([example](/example/objc/objc_grpc_compile)) |
| [Objective-C](/objc) | [objc_proto_library](/objc#objc_proto_library) | Generates an Objective-C protobuf library using `objc_library` ([example](/example/objc/objc_proto_library)) |

View File

@ -162,13 +162,6 @@ load("@grpc_ecosystem_grpc_gateway//:repositories.bzl", "go_repositories")
go_repositories()
#
# gRPC web
#
load("//grpc-web:repositories.bzl", "grpc_web_repos")
grpc_web_repos()
#
# Java
#

View File

@ -134,34 +134,6 @@ grpc-gateway_gateway_grpc_library_example:
.PHONY: grpc-gateway_examples
grpc-gateway_examples: grpc-gateway_gateway_grpc_compile_example grpc-gateway_gateway_openapiv2_compile_example grpc-gateway_gateway_grpc_library_example
.PHONY: grpc-web_closure_grpc_compile_example
grpc-web_closure_grpc_compile_example:
cd example/grpc-web/closure_grpc_compile; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: grpc-web_commonjs_grpc_compile_example
grpc-web_commonjs_grpc_compile_example:
cd example/grpc-web/commonjs_grpc_compile; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: grpc-web_commonjs_dts_grpc_compile_example
grpc-web_commonjs_dts_grpc_compile_example:
cd example/grpc-web/commonjs_dts_grpc_compile; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: grpc-web_ts_grpc_compile_example
grpc-web_ts_grpc_compile_example:
cd example/grpc-web/ts_grpc_compile; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: grpc-web_closure_grpc_library_example
grpc-web_closure_grpc_library_example:
cd example/grpc-web/closure_grpc_library; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: grpc-web_examples
grpc-web_examples: grpc-web_closure_grpc_compile_example grpc-web_commonjs_grpc_compile_example grpc-web_commonjs_dts_grpc_compile_example grpc-web_ts_grpc_compile_example grpc-web_closure_grpc_library_example
.PHONY: java_java_proto_compile_example
java_java_proto_compile_example:
cd example/java/java_proto_compile; \
@ -190,9 +162,14 @@ js_js_proto_compile_example:
cd example/js/js_proto_compile; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: js_nodejs_grpc_compile_example
js_nodejs_grpc_compile_example:
cd example/js/nodejs_grpc_compile; \
.PHONY: js_js_grpc_node_compile_example
js_js_grpc_node_compile_example:
cd example/js/js_grpc_node_compile; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: js_js_grpc_web_compile_example
js_js_grpc_web_compile_example:
cd example/js/js_grpc_web_compile; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: js_js_proto_library_example
@ -200,13 +177,18 @@ js_js_proto_library_example:
cd example/js/js_proto_library; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: js_nodejs_grpc_library_example
js_nodejs_grpc_library_example:
cd example/js/nodejs_grpc_library; \
.PHONY: js_js_grpc_node_library_example
js_js_grpc_node_library_example:
cd example/js/js_grpc_node_library; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: js_js_grpc_web_library_example
js_js_grpc_web_library_example:
cd example/js/js_grpc_web_library; \
bazel --batch build --verbose_failures --disk_cache=../../bazel-disk-cache //...
.PHONY: js_examples
js_examples: js_js_proto_compile_example js_nodejs_grpc_compile_example js_js_proto_library_example js_nodejs_grpc_library_example
js_examples: js_js_proto_compile_example js_js_grpc_node_compile_example js_js_grpc_web_compile_example js_js_proto_library_example js_js_grpc_node_library_example js_js_grpc_web_library_example
.PHONY: objc_objc_proto_compile_example
objc_objc_proto_compile_example:
@ -365,4 +347,4 @@ swift_swift_grpc_library_example:
swift_examples: swift_swift_proto_compile_example swift_swift_grpc_compile_example swift_swift_proto_library_example swift_swift_grpc_library_example
.PHONY: all_examples
all_examples: android_android_proto_compile_example android_android_grpc_compile_example android_android_proto_library_example android_android_grpc_library_example closure_closure_proto_compile_example closure_closure_proto_library_example cpp_cpp_proto_compile_example cpp_cpp_grpc_compile_example cpp_cpp_proto_library_example cpp_cpp_grpc_library_example csharp_csharp_proto_compile_example csharp_csharp_grpc_compile_example csharp_csharp_proto_library_example csharp_csharp_grpc_library_example d_d_proto_compile_example d_d_proto_library_example go_go_proto_compile_example go_go_grpc_compile_example go_go_proto_library_example go_go_grpc_library_example grpc-gateway_gateway_grpc_compile_example grpc-gateway_gateway_openapiv2_compile_example grpc-gateway_gateway_grpc_library_example grpc-web_closure_grpc_compile_example grpc-web_commonjs_grpc_compile_example grpc-web_commonjs_dts_grpc_compile_example grpc-web_ts_grpc_compile_example grpc-web_closure_grpc_library_example java_java_proto_compile_example java_java_grpc_compile_example java_java_proto_library_example java_java_grpc_library_example js_js_proto_compile_example js_nodejs_grpc_compile_example js_js_proto_library_example js_nodejs_grpc_library_example objc_objc_proto_compile_example objc_objc_grpc_compile_example objc_objc_proto_library_example php_php_proto_compile_example php_php_grpc_compile_example python_python_proto_compile_example python_python_grpc_compile_example python_python_grpclib_compile_example python_python_proto_library_example python_python_grpc_library_example python_python_grpclib_library_example ruby_ruby_proto_compile_example ruby_ruby_grpc_compile_example ruby_ruby_proto_library_example ruby_ruby_grpc_library_example rust_rust_proto_compile_example rust_rust_grpc_compile_example rust_rust_proto_library_example rust_rust_grpc_library_example scala_scala_proto_compile_example scala_scala_grpc_compile_example scala_scala_proto_library_example scala_scala_grpc_library_example swift_swift_proto_compile_example swift_swift_grpc_compile_example swift_swift_proto_library_example swift_swift_grpc_library_example
all_examples: android_android_proto_compile_example android_android_grpc_compile_example android_android_proto_library_example android_android_grpc_library_example closure_closure_proto_compile_example closure_closure_proto_library_example cpp_cpp_proto_compile_example cpp_cpp_grpc_compile_example cpp_cpp_proto_library_example cpp_cpp_grpc_library_example csharp_csharp_proto_compile_example csharp_csharp_grpc_compile_example csharp_csharp_proto_library_example csharp_csharp_grpc_library_example d_d_proto_compile_example d_d_proto_library_example go_go_proto_compile_example go_go_grpc_compile_example go_go_proto_library_example go_go_grpc_library_example grpc-gateway_gateway_grpc_compile_example grpc-gateway_gateway_openapiv2_compile_example grpc-gateway_gateway_grpc_library_example java_java_proto_compile_example java_java_grpc_compile_example java_java_proto_library_example java_java_grpc_library_example js_js_proto_compile_example js_js_grpc_node_compile_example js_js_grpc_web_compile_example js_js_proto_library_example js_js_grpc_node_library_example js_js_grpc_web_library_example objc_objc_proto_compile_example objc_objc_grpc_compile_example objc_objc_proto_library_example php_php_proto_compile_example php_php_grpc_compile_example python_python_proto_compile_example python_python_grpc_compile_example python_python_grpclib_compile_example python_python_proto_library_example python_python_grpc_library_example python_python_grpclib_library_example ruby_ruby_proto_compile_example ruby_ruby_grpc_compile_example ruby_ruby_proto_library_example ruby_ruby_grpc_library_example rust_rust_proto_compile_example rust_rust_grpc_compile_example rust_rust_proto_library_example rust_rust_grpc_library_example scala_scala_proto_compile_example scala_scala_grpc_compile_example scala_scala_proto_library_example scala_scala_grpc_library_example swift_swift_proto_compile_example swift_swift_grpc_compile_example swift_swift_proto_library_example swift_swift_grpc_library_example

View File

@ -1,11 +0,0 @@
load("@rules_proto_grpc//grpc-web:defs.bzl", "closure_grpc_compile")
closure_grpc_compile(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
closure_grpc_compile(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)

View File

@ -1,12 +0,0 @@
load("@rules_proto_grpc//grpc-web:defs.bzl", "closure_grpc_library")
closure_grpc_library(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
closure_grpc_library(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
deps = ["thing_grpc-web_grpc"],
)

View File

@ -1,28 +0,0 @@
local_repository(
name = "rules_proto_grpc",
path = "../../../",
)
load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")
rules_proto_grpc_toolchains()
rules_proto_grpc_repos()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
rules_proto_grpc_grpc_web_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
rules_closure_dependencies(
omit_com_google_protobuf = True,
)
rules_closure_toolchains()

View File

@ -1,11 +0,0 @@
load("@rules_proto_grpc//grpc-web:defs.bzl", "commonjs_dts_grpc_compile")
commonjs_dts_grpc_compile(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
commonjs_dts_grpc_compile(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)

View File

@ -1,11 +0,0 @@
load("@rules_proto_grpc//grpc-web:defs.bzl", "commonjs_grpc_compile")
commonjs_grpc_compile(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
commonjs_grpc_compile(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)

View File

@ -1,28 +0,0 @@
local_repository(
name = "rules_proto_grpc",
path = "../../../",
)
load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")
rules_proto_grpc_toolchains()
rules_proto_grpc_repos()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
rules_proto_grpc_grpc_web_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
rules_closure_dependencies(
omit_com_google_protobuf = True,
)
rules_closure_toolchains()

View File

@ -1,11 +0,0 @@
load("@rules_proto_grpc//grpc-web:defs.bzl", "ts_grpc_compile")
ts_grpc_compile(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
ts_grpc_compile(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)

View File

@ -1,28 +0,0 @@
local_repository(
name = "rules_proto_grpc",
path = "../../../",
)
load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")
rules_proto_grpc_toolchains()
rules_proto_grpc_repos()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
rules_proto_grpc_grpc_web_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
rules_closure_dependencies(
omit_com_google_protobuf = True,
)
rules_closure_toolchains()

View File

@ -0,0 +1,11 @@
load("@rules_proto_grpc//js:defs.bzl", "js_grpc_node_compile")
js_grpc_node_compile(
name = "thing_js_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
js_grpc_node_compile(
name = "greeter_js_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)

View File

@ -1,11 +1,11 @@
load("@rules_proto_grpc//js:defs.bzl", "nodejs_grpc_library")
load("@rules_proto_grpc//js:defs.bzl", "js_grpc_node_library")
nodejs_grpc_library(
js_grpc_node_library(
name = "thing_js_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
nodejs_grpc_library(
js_grpc_node_library(
name = "greeter_js_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
deps = ["thing_js_grpc"],

View File

@ -1,11 +1,11 @@
load("@rules_proto_grpc//js:defs.bzl", "nodejs_grpc_compile")
load("@rules_proto_grpc//js:defs.bzl", "js_grpc_web_compile")
nodejs_grpc_compile(
js_grpc_web_compile(
name = "thing_js_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
nodejs_grpc_compile(
js_grpc_web_compile(
name = "greeter_js_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)

View File

@ -15,14 +15,14 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
load("@rules_proto_grpc//js:repositories.bzl", rules_proto_grpc_js_repos = "js_repos")
rules_proto_grpc_grpc_web_repos()
rules_proto_grpc_js_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
rules_closure_dependencies(
omit_com_google_protobuf = True,
yarn_install(
name = "js_modules",
package_json = "@rules_proto_grpc//js:requirements/package.json",
yarn_lock = "@rules_proto_grpc//js:requirements/yarn.lock",
)
rules_closure_toolchains()

View File

@ -0,0 +1,18 @@
load("@rules_proto_grpc//js:defs.bzl", "js_grpc_web_library")
js_grpc_web_library(
name = "person_js_grpc",
protos = ["@rules_proto_grpc//example/proto:person_proto"],
deps = ["place_js_grpc"],
)
js_grpc_web_library(
name = "place_js_grpc",
protos = ["@rules_proto_grpc//example/proto:place_proto"],
deps = ["thing_js_grpc"],
)
js_grpc_web_library(
name = "thing_js_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)

View File

@ -15,14 +15,14 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
load("@rules_proto_grpc//js:repositories.bzl", rules_proto_grpc_js_repos = "js_repos")
rules_proto_grpc_grpc_web_repos()
rules_proto_grpc_js_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
rules_closure_dependencies(
omit_com_google_protobuf = True,
yarn_install(
name = "js_modules",
package_json = "@rules_proto_grpc//js:requirements/package.json",
yarn_lock = "@rules_proto_grpc//js:requirements/yarn.lock",
)
rules_closure_toolchains()

View File

@ -1,45 +0,0 @@
load("//:defs.bzl", "proto_plugin")
proto_plugin(
name = "closure_plugin",
options = [
"import_style=closure",
"mode=grpcweb",
],
output_directory = True, # Plugin outputs cannot be predicted as they depend on service/package name
tool = "@com_github_grpc_grpc_web//javascript/net/grpc/web:protoc-gen-grpc-web",
visibility = ["//visibility:public"],
)
proto_plugin(
name = "commonjs_plugin",
options = [
"import_style=commonjs",
"mode=grpcweb",
],
output_directory = True, # Plugin outputs cannot be predicted as they depend on service/package name
tool = "@com_github_grpc_grpc_web//javascript/net/grpc/web:protoc-gen-grpc-web",
visibility = ["//visibility:public"],
)
proto_plugin(
name = "commonjs_dts_plugin",
options = [
"import_style=commonjs+dts",
"mode=grpcweb",
],
output_directory = True, # Plugin outputs cannot be predicted as they depend on service/package name
tool = "@com_github_grpc_grpc_web//javascript/net/grpc/web:protoc-gen-grpc-web",
visibility = ["//visibility:public"],
)
proto_plugin(
name = "ts_plugin",
options = [
"import_style=typescript",
"mode=grpcweb",
],
output_directory = True, # Plugin outputs cannot be predicted as they depend on service/package name
tool = "@com_github_grpc_grpc_web//javascript/net/grpc/web:protoc-gen-grpc-web",
visibility = ["//visibility:public"],
)

View File

@ -1,267 +0,0 @@
# gRPC-Web rules
| Rule | Description |
| ---: | :--- |
| [closure_grpc_compile](#closure_grpc_compile) | Generates Closure *.js protobuf+gRPC files |
| [commonjs_grpc_compile](#commonjs_grpc_compile) | Generates CommonJS *.js protobuf+gRPC files |
| [commonjs_dts_grpc_compile](#commonjs_dts_grpc_compile) | Generates commonjs_dts *.js protobuf+gRPC files |
| [ts_grpc_compile](#ts_grpc_compile) | Generates CommonJS *.ts protobuf+gRPC files |
| [closure_grpc_library](#closure_grpc_library) | Generates protobuf closure library *.js files |
---
## `closure_grpc_compile`
Generates Closure *.js protobuf+gRPC files
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
rules_proto_grpc_grpc_web_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
rules_closure_dependencies(
omit_com_google_protobuf = True,
)
rules_closure_toolchains()
```
### `BUILD.bazel`
```starlark
load("@rules_proto_grpc//grpc-web:defs.bzl", "closure_grpc_compile")
closure_grpc_compile(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
closure_grpc_compile(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)
```
### Attributes
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `prefix_path` | `string` | false | `` | Path to prefix to the generated files in the output directory |
| `extra_protoc_args` | `list<string>` | false | `[]` | A list of extra args to pass directly to protoc, not as plugin options |
### Plugins
- `@rules_proto_grpc//grpc-web:closure_plugin`
---
## `commonjs_grpc_compile`
Generates CommonJS *.js protobuf+gRPC files
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
rules_proto_grpc_grpc_web_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
rules_closure_dependencies(
omit_com_google_protobuf = True,
)
rules_closure_toolchains()
```
### `BUILD.bazel`
```starlark
load("@rules_proto_grpc//grpc-web:defs.bzl", "commonjs_grpc_compile")
commonjs_grpc_compile(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
commonjs_grpc_compile(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)
```
### Attributes
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `prefix_path` | `string` | false | `` | Path to prefix to the generated files in the output directory |
| `extra_protoc_args` | `list<string>` | false | `[]` | A list of extra args to pass directly to protoc, not as plugin options |
### Plugins
- `@rules_proto_grpc//grpc-web:commonjs_plugin`
---
## `commonjs_dts_grpc_compile`
Generates commonjs_dts *.js protobuf+gRPC files
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
rules_proto_grpc_grpc_web_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
rules_closure_dependencies(
omit_com_google_protobuf = True,
)
rules_closure_toolchains()
```
### `BUILD.bazel`
```starlark
load("@rules_proto_grpc//grpc-web:defs.bzl", "commonjs_dts_grpc_compile")
commonjs_dts_grpc_compile(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
commonjs_dts_grpc_compile(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)
```
### Attributes
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `prefix_path` | `string` | false | `` | Path to prefix to the generated files in the output directory |
| `extra_protoc_args` | `list<string>` | false | `[]` | A list of extra args to pass directly to protoc, not as plugin options |
### Plugins
- `@rules_proto_grpc//grpc-web:commonjs_dts_plugin`
---
## `ts_grpc_compile`
Generates CommonJS *.ts protobuf+gRPC files
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
rules_proto_grpc_grpc_web_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
rules_closure_dependencies(
omit_com_google_protobuf = True,
)
rules_closure_toolchains()
```
### `BUILD.bazel`
```starlark
load("@rules_proto_grpc//grpc-web:defs.bzl", "ts_grpc_compile")
ts_grpc_compile(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
ts_grpc_compile(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)
```
### Attributes
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `prefix_path` | `string` | false | `` | Path to prefix to the generated files in the output directory |
| `extra_protoc_args` | `list<string>` | false | `[]` | A list of extra args to pass directly to protoc, not as plugin options |
### Plugins
- `@rules_proto_grpc//grpc-web:ts_plugin`
---
## `closure_grpc_library`
Generates protobuf closure library *.js files
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//grpc-web:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
rules_proto_grpc_grpc_web_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
rules_closure_dependencies(
omit_com_google_protobuf = True,
)
rules_closure_toolchains()
```
### `BUILD.bazel`
```starlark
load("@rules_proto_grpc//grpc-web:defs.bzl", "closure_grpc_library")
closure_grpc_library(
name = "thing_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
closure_grpc_library(
name = "greeter_grpc-web_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
deps = ["thing_grpc-web_grpc"],
)
```
### Attributes
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `prefix_path` | `string` | false | `` | Path to prefix to the generated files in the output directory |
| `extra_protoc_args` | `list<string>` | false | `[]` | A list of extra args to pass directly to protoc, not as plugin options |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |

View File

@ -1,59 +0,0 @@
"""Generated definition of closure_grpc_library."""
load("//grpc-web:closure_grpc_compile.bzl", "closure_grpc_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("//closure:closure_proto_compile.bzl", "closure_proto_compile")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
def closure_grpc_library(**kwargs): # buildifier: disable=function-docstring
# Compile protos
name_pb = kwargs.get("name") + "_pb"
name_pb_grpc = kwargs.get("name") + "_pb_grpc"
closure_proto_compile(
name = name_pb,
**{
k: v
for (k, v) in kwargs.items()
if k in ["protos" if "protos" in kwargs else "deps"] + proto_compile_attrs.keys()
} # Forward args
)
closure_grpc_compile(
name = name_pb_grpc,
**{
k: v
for (k, v) in kwargs.items()
if k in ["protos" if "protos" in kwargs else "deps"] + proto_compile_attrs.keys()
} # Forward args
)
# Create closure library
closure_js_library(
name = kwargs.get("name"),
srcs = [name_pb, name_pb_grpc],
deps = GRPC_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),
suppress = [
"JSC_LATE_PROVIDE_ERROR",
"JSC_UNDEFINED_VARIABLE",
"JSC_IMPLICITLY_NULLABLE_JSDOC",
"JSC_STRICT_INEXISTENT_PROPERTY",
"JSC_POSSIBLE_INEXISTENT_PROPERTY",
"JSC_UNRECOGNIZED_TYPE_ERROR",
"JSC_UNUSED_PRIVATE_PROPERTY",
"JSC_EXTRA_REQUIRE_WARNING",
"JSC_INVALID_INTERFACE_MEMBER_DECLARATION",
"JSC_TYPE_MISMATCH",
"CR_NOT_PROVIDED",
],
visibility = kwargs.get("visibility"),
tags = kwargs.get("tags"),
)
GRPC_DEPS = [
"@com_github_grpc_grpc_web//javascript/net/grpc/web:abstractclientbase",
"@com_github_grpc_grpc_web//javascript/net/grpc/web:clientreadablestream",
"@com_github_grpc_grpc_web//javascript/net/grpc/web:grpcwebclientbase",
"@com_github_grpc_grpc_web//javascript/net/grpc/web:error",
"@io_bazel_rules_closure//closure/library",
"@io_bazel_rules_closure//closure/protobuf:jspb",
]

View File

@ -1,69 +0,0 @@
"""Generated definition of commonjs_dts_grpc_compile."""
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
load(
"//:defs.bzl",
"ProtoLibraryAspectNodeInfo",
"ProtoPluginInfo",
"proto_compile_aspect_attrs",
"proto_compile_aspect_impl",
"proto_compile_attrs",
"proto_compile_impl",
)
# Create aspect for commonjs_dts_grpc_compile
commonjs_dts_grpc_compile_aspect = aspect(
implementation = proto_compile_aspect_impl,
provides = [ProtoLibraryAspectNodeInfo],
attr_aspects = ["deps"],
attrs = dict(
proto_compile_aspect_attrs,
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//grpc-web:commonjs_dts_plugin"),
],
),
_prefix = attr.string(
doc = "String used to disambiguate aspects when generating outputs",
default = "commonjs_dts_grpc_compile_aspect",
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)
# Create compile rule to apply aspect
_rule = rule(
implementation = proto_compile_impl,
attrs = dict(
proto_compile_attrs,
protos = attr.label_list(
mandatory = False, # TODO: set to true in 4.0.0 when deps removed below
providers = [ProtoInfo, ProtoLibraryAspectNodeInfo],
aspects = [commonjs_dts_grpc_compile_aspect],
doc = "List of labels that provide a ProtoInfo (such as rules_proto proto_library)",
),
deps = attr.label_list(
mandatory = False,
providers = [ProtoInfo, ProtoLibraryAspectNodeInfo],
aspects = [commonjs_dts_grpc_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//grpc-web:commonjs_dts_plugin"),
],
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)
# Create macro for converting attrs and passing to compile
def commonjs_dts_grpc_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
**kwargs
)

View File

@ -1,14 +0,0 @@
"""grpc-web protobuf and grpc rules."""
load(":closure_grpc_compile.bzl", _closure_grpc_compile = "closure_grpc_compile")
load(":commonjs_grpc_compile.bzl", _commonjs_grpc_compile = "commonjs_grpc_compile")
load(":commonjs_dts_grpc_compile.bzl", _commonjs_dts_grpc_compile = "commonjs_dts_grpc_compile")
load(":ts_grpc_compile.bzl", _ts_grpc_compile = "ts_grpc_compile")
load(":closure_grpc_library.bzl", _closure_grpc_library = "closure_grpc_library")
# Export grpc-web rules
closure_grpc_compile = _closure_grpc_compile
commonjs_grpc_compile = _commonjs_grpc_compile
commonjs_dts_grpc_compile = _commonjs_dts_grpc_compile
ts_grpc_compile = _ts_grpc_compile
closure_grpc_library = _closure_grpc_library

View File

@ -1,65 +0,0 @@
load(
"@io_bazel_rules_closure//closure:defs.bzl",
"closure_js_binary",
"closure_js_library",
"closure_js_test",
)
load("//grpc-web:defs.bzl", "closure_grpc_library")
closure_grpc_library(
name = "routeguide",
protos = [
"//example/proto:routeguide_proto",
],
)
closure_js_test(
name = "client_test",
size = "small",
srcs = [
"client_test.js",
],
entry_points = ["example.routeguide.grpc_web.ClientTest"],
deps = [
":client",
":routeguide",
"@io_bazel_rules_closure//closure/library/testing:asserts",
"@io_bazel_rules_closure//closure/library/testing:jsunit",
"@io_bazel_rules_closure//closure/library/testing:testsuite",
],
)
closure_js_library(
name = "client",
srcs = [
"client.js",
],
deps = [
":routeguide",
"@com_github_grpc_grpc_web//javascript/net/grpc/web:clientreadablestream",
],
)
closure_js_library(
name = "main",
srcs = [
"main.js",
],
suppress = [
"JSC_INVALID_CLOSURE_CALL_ERROR",
],
deps = [
":client",
],
)
closure_js_binary(
name = "bundle",
compilation_level = "ADVANCED",
debug = False,
entry_points = ["goog:example.routeguide.grpc_web.client.run"],
output_wrapper = "(function(){%output%}).call(this);",
deps = [
":main",
],
)

View File

@ -1,46 +0,0 @@
goog.module('example.routeguide.grpc_web.Client');
const ClientReadableStream = goog.require('grpc.web.ClientReadableStream');
const Feature = goog.require('proto.routeguide.Feature');
const Rectangle = goog.require('proto.routeguide.Rectangle');
const RouteGuideClient = goog.require('proto.routeguide.RouteGuideClient');
/**
* A skeleton client. The point of this exercise is not actually to create a
* routeguide client, but show how we can use protobufs in closure code.
*/
class Client {
/**
* @param {string} hostname
* @param {?Object} credentials
* @param {?Object} options
*/
constructor(hostname, credentials, options) {
/**
* @const @private @type {!RouteGuideClient}
*/
this.client_ = new RouteGuideClient(hostname, credentials, options);
}
/**
* List existing features. Promise resolves to a list of features.
*
* @param {!Rectangle} rect
* @param {!Object} metadata
* @return {!ClientReadableStream<!Feature>}
*/
listFeatures(rect, metadata) {
return this.client_.listFeatures(rect, metadata);
}
/**
* Run the client. A real implementation might actually do something here.
*/
run() {
console.log("Running grpc-web routeguide client...");
}
}
exports = Client;

View File

@ -1,25 +0,0 @@
goog.module('example.routeguide.grpc_web.ClientTest');
goog.setTestOnly('example.routeguide.grpc_web.ClientTest');
const Client = goog.require('example.routeguide.grpc_web.Client');
const Rectangle = goog.require('proto.routeguide.Rectangle');
const asserts = goog.require('goog.testing.asserts');
const testSuite = goog.require('goog.testing.testSuite');
goog.require('goog.testing.jsunit');
testSuite({
testListFeatures: () => {
const client = new Client("localhost", null, null);
const rect = new Rectangle();
// Currently this segfaults phantomjs!
const stream = client.listFeatures(rect, {});
asserts.assertNotNull(stream);
},
});

View File

@ -1,10 +0,0 @@
goog.module('example.routeguide.grpc_web.client.run');
/**
* Main entry point
*/
exports = function() {
const Client = goog.require('example.routeguide.grpc_web.Client');
const client = new Client("localhost", null, null);
client.run();
};

View File

@ -1,14 +0,0 @@
"""Common dependencies for rules_proto_grpc gRPC web rules."""
load(
"//:repositories.bzl",
"com_github_grpc_grpc_web",
)
load(
"//closure:repositories.bzl",
"closure_repos",
)
def grpc_web_repos(**kwargs): # buildifier: disable=function-docstring
closure_repos(**kwargs)
com_github_grpc_grpc_web(**kwargs)

View File

@ -1,69 +0,0 @@
"""Generated definition of ts_grpc_compile."""
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
load(
"//:defs.bzl",
"ProtoLibraryAspectNodeInfo",
"ProtoPluginInfo",
"proto_compile_aspect_attrs",
"proto_compile_aspect_impl",
"proto_compile_attrs",
"proto_compile_impl",
)
# Create aspect for ts_grpc_compile
ts_grpc_compile_aspect = aspect(
implementation = proto_compile_aspect_impl,
provides = [ProtoLibraryAspectNodeInfo],
attr_aspects = ["deps"],
attrs = dict(
proto_compile_aspect_attrs,
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//grpc-web:ts_plugin"),
],
),
_prefix = attr.string(
doc = "String used to disambiguate aspects when generating outputs",
default = "ts_grpc_compile_aspect",
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)
# Create compile rule to apply aspect
_rule = rule(
implementation = proto_compile_impl,
attrs = dict(
proto_compile_attrs,
protos = attr.label_list(
mandatory = False, # TODO: set to true in 4.0.0 when deps removed below
providers = [ProtoInfo, ProtoLibraryAspectNodeInfo],
aspects = [ts_grpc_compile_aspect],
doc = "List of labels that provide a ProtoInfo (such as rules_proto proto_library)",
),
deps = attr.label_list(
mandatory = False,
providers = [ProtoInfo, ProtoLibraryAspectNodeInfo],
aspects = [ts_grpc_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//grpc-web:ts_plugin"),
],
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)
# Create macro for converting attrs and passing to compile
def ts_grpc_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
**kwargs
)

View File

@ -1,5 +1,6 @@
load("//:defs.bzl", "proto_plugin")
# Proto
proto_plugin(
name = "js_plugin",
exclusions = [
@ -21,6 +22,7 @@ proto_plugin(
visibility = ["//visibility:public"],
)
# grpc-node
proto_plugin(
name = "grpc_node_plugin",
exclusions = [
@ -43,3 +45,19 @@ proto_plugin(
tool = "@js_modules//ts-protoc-gen/bin:protoc-gen-ts",
visibility = ["//visibility:public"],
)
# grpc-web
proto_plugin(
name = "grpc_web_js_plugin",
options = [
"import_style=commonjs+dts",
"mode=grpcweb",
],
output_directory = True,
tool = select({
"@bazel_tools//src/conditions:darwin_x86_64": "@grpc_web_plugin_darwin//file",
"@bazel_tools//src/conditions:linux_x86_64": "@grpc_web_plugin_linux//file",
"@bazel_tools//src/conditions:windows": "@grpc_web_plugin_windows//file",
}),
visibility = ["//visibility:public"],
)

View File

@ -1,13 +1,15 @@
# JavaScript rules
Rules for generating JavaScript protobuf and gRPC `.js` and `.d.ts` files using standard Protocol Buffers and gRPC.
Rules for generating JavaScript protobuf, gRPC-node and gRPC-Web `.js` and `.d.ts` files using standard Protocol Buffers and gRPC.
| Rule | Description |
| ---: | :--- |
| [js_proto_compile](#js_proto_compile) | Generates JavaScript protobuf `.js` and `.d.ts` artifacts |
| [nodejs_grpc_compile](#nodejs_grpc_compile) | Generates JavaScript protobuf + Node.js gRPC `.js` and `.d.ts` artifacts |
| [js_grpc_node_compile](#js_grpc_node_compile) | Generates JavaScript protobuf + gRPC-node `.js` and `.d.ts` artifacts |
| [js_grpc_web_compile](#js_grpc_web_compile) | Generates JavaScript protobuf + gRPC-Web `.js` and `.d.ts` artifacts |
| [js_proto_library](#js_proto_library) | Generates a JavaScript protobuf library using `js_library` from `rules_nodejs` |
| [nodejs_grpc_library](#nodejs_grpc_library) | Generates a Node.js protobuf+gRPC library using `js_library` from `rules_nodejs` |
| [js_grpc_node_library](#js_grpc_node_library) | Generates a Node.js protobuf + gRPC-node library using `js_library` from `rules_nodejs` |
| [js_grpc_web_library](#js_grpc_web_library) | Generates a JavaScript protobuf + gRPC-Web library using `js_library` from `rules_nodejs` |
---
@ -69,9 +71,9 @@ js_proto_compile(
---
## `nodejs_grpc_compile`
## `js_grpc_node_compile`
Generates JavaScript protobuf + Node.js gRPC `.js` and `.d.ts` artifacts
Generates JavaScript protobuf + gRPC-node `.js` and `.d.ts` artifacts
### `WORKSPACE`
@ -92,14 +94,14 @@ yarn_install(
### `BUILD.bazel`
```starlark
load("@rules_proto_grpc//js:defs.bzl", "nodejs_grpc_compile")
load("@rules_proto_grpc//js:defs.bzl", "js_grpc_node_compile")
nodejs_grpc_compile(
js_grpc_node_compile(
name = "thing_js_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
nodejs_grpc_compile(
js_grpc_node_compile(
name = "greeter_js_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)
@ -123,6 +125,59 @@ nodejs_grpc_compile(
---
## `js_grpc_web_compile`
Generates JavaScript protobuf + gRPC-Web `.js` and `.d.ts` artifacts
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//js:repositories.bzl", rules_proto_grpc_js_repos = "js_repos")
rules_proto_grpc_js_repos()
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
yarn_install(
name = "js_modules",
package_json = "@rules_proto_grpc//js:requirements/package.json",
yarn_lock = "@rules_proto_grpc//js:requirements/yarn.lock",
)
```
### `BUILD.bazel`
```starlark
load("@rules_proto_grpc//js:defs.bzl", "js_grpc_web_compile")
js_grpc_web_compile(
name = "thing_js_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
js_grpc_web_compile(
name = "greeter_js_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)
```
### Attributes
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `prefix_path` | `string` | false | `` | Path to prefix to the generated files in the output directory |
| `extra_protoc_args` | `list<string>` | false | `[]` | A list of extra args to pass directly to protoc, not as plugin options |
### Plugins
- `@rules_proto_grpc//js:js_plugin`
- `@rules_proto_grpc//js:grpc_web_js_plugin`
---
## `js_proto_library`
Generates a JavaScript protobuf library using `js_library` from `rules_nodejs`
@ -179,9 +234,9 @@ js_proto_library(
---
## `nodejs_grpc_library`
## `js_grpc_node_library`
Generates a Node.js protobuf+gRPC library using `js_library` from `rules_nodejs`
Generates a Node.js protobuf + gRPC-node library using `js_library` from `rules_nodejs`
### `WORKSPACE`
@ -202,14 +257,14 @@ yarn_install(
### `BUILD.bazel`
```starlark
load("@rules_proto_grpc//js:defs.bzl", "nodejs_grpc_library")
load("@rules_proto_grpc//js:defs.bzl", "js_grpc_node_library")
nodejs_grpc_library(
js_grpc_node_library(
name = "thing_js_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
nodejs_grpc_library(
js_grpc_node_library(
name = "greeter_js_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
deps = ["thing_js_grpc"],
@ -226,3 +281,59 @@ nodejs_grpc_library(
| `prefix_path` | `string` | false | `` | Path to prefix to the generated files in the output directory |
| `extra_protoc_args` | `list<string>` | false | `[]` | A list of extra args to pass directly to protoc, not as plugin options |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
---
## `js_grpc_web_library`
Generates a JavaScript protobuf + gRPC-Web library using `js_library` from `rules_nodejs`
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//js:repositories.bzl", rules_proto_grpc_js_repos = "js_repos")
rules_proto_grpc_js_repos()
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
yarn_install(
name = "js_modules",
package_json = "@rules_proto_grpc//js:requirements/package.json",
yarn_lock = "@rules_proto_grpc//js:requirements/yarn.lock",
)
```
### `BUILD.bazel`
```starlark
load("@rules_proto_grpc//js:defs.bzl", "js_grpc_web_library")
js_grpc_web_library(
name = "person_js_grpc",
protos = ["@rules_proto_grpc//example/proto:person_proto"],
deps = ["place_js_grpc"],
)
js_grpc_web_library(
name = "place_js_grpc",
protos = ["@rules_proto_grpc//example/proto:place_proto"],
deps = ["thing_js_grpc"],
)
js_grpc_web_library(
name = "thing_js_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
```
### Attributes
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `prefix_path` | `string` | false | `` | Path to prefix to the generated files in the output directory |
| `extra_protoc_args` | `list<string>` | false | `[]` | A list of extra args to pass directly to protoc, not as plugin options |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |

View File

@ -1,16 +1,22 @@
"""js protobuf and grpc rules."""
load(":js_proto_compile.bzl", _js_proto_compile = "js_proto_compile")
load(":nodejs_grpc_compile.bzl", _nodejs_grpc_compile = "nodejs_grpc_compile")
load(":js_grpc_node_compile.bzl", _js_grpc_node_compile = "js_grpc_node_compile")
load(":js_grpc_web_compile.bzl", _js_grpc_web_compile = "js_grpc_web_compile")
load(":js_proto_library.bzl", _js_proto_library = "js_proto_library")
load(":nodejs_grpc_library.bzl", _nodejs_grpc_library = "nodejs_grpc_library")
load(":js_grpc_node_library.bzl", _js_grpc_node_library = "js_grpc_node_library")
load(":js_grpc_web_library.bzl", _js_grpc_web_library = "js_grpc_web_library")
# Export js rules
js_proto_compile = _js_proto_compile
nodejs_grpc_compile = _nodejs_grpc_compile
js_grpc_node_compile = _js_grpc_node_compile
js_grpc_web_compile = _js_grpc_web_compile
js_proto_library = _js_proto_library
nodejs_grpc_library = _nodejs_grpc_library
js_grpc_node_library = _js_grpc_node_library
js_grpc_web_library = _js_grpc_web_library
# Aliases
nodejs_grpc_compile = _js_grpc_node_compile
nodejs_grpc_library = _js_grpc_node_library
nodejs_proto_compile = _js_proto_compile
nodejs_proto_library = _js_proto_library

View File

@ -1,4 +1,4 @@
"""Generated definition of closure_grpc_compile."""
"""Generated definition of js_grpc_node_compile."""
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
load(
@ -11,8 +11,8 @@ load(
"proto_compile_impl",
)
# Create aspect for closure_grpc_compile
closure_grpc_compile_aspect = aspect(
# Create aspect for js_grpc_node_compile
js_grpc_node_compile_aspect = aspect(
implementation = proto_compile_aspect_impl,
provides = [ProtoLibraryAspectNodeInfo],
attr_aspects = ["deps"],
@ -22,12 +22,14 @@ closure_grpc_compile_aspect = aspect(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//grpc-web:closure_plugin"),
Label("//js:js_plugin"),
Label("//js:grpc_node_plugin"),
Label("//js:grpc_node_ts_plugin"),
],
),
_prefix = attr.string(
doc = "String used to disambiguate aspects when generating outputs",
default = "closure_grpc_compile_aspect",
default = "js_grpc_node_compile_aspect",
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
@ -41,20 +43,22 @@ _rule = rule(
protos = attr.label_list(
mandatory = False, # TODO: set to true in 4.0.0 when deps removed below
providers = [ProtoInfo, ProtoLibraryAspectNodeInfo],
aspects = [closure_grpc_compile_aspect],
aspects = [js_grpc_node_compile_aspect],
doc = "List of labels that provide a ProtoInfo (such as rules_proto proto_library)",
),
deps = attr.label_list(
mandatory = False,
providers = [ProtoInfo, ProtoLibraryAspectNodeInfo],
aspects = [closure_grpc_compile_aspect],
aspects = [js_grpc_node_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//grpc-web:closure_plugin"),
Label("//js:js_plugin"),
Label("//js:grpc_node_plugin"),
Label("//js:grpc_node_ts_plugin"),
],
),
),
@ -62,7 +66,7 @@ _rule = rule(
)
# Create macro for converting attrs and passing to compile
def closure_grpc_compile(**kwargs):
def js_grpc_node_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
**kwargs

View File

@ -0,0 +1,32 @@
"""Generated definition of js_grpc_node_library."""
load("//js:js_grpc_node_compile.bzl", "js_grpc_node_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
def js_grpc_node_library(**kwargs):
# Compile protos
name_pb = kwargs.get("name") + "_pb"
js_grpc_node_compile(
name = name_pb,
**{
k: v
for (k, v) in kwargs.items()
if k in ["protos" if "protos" in kwargs else "deps"] + proto_compile_attrs.keys()
} # Forward args
)
# Create js library
js_library(
name = kwargs.get("name"),
srcs = [name_pb],
deps = GRPC_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),
package_name = kwargs.get("name"),
visibility = kwargs.get("visibility"),
tags = kwargs.get("tags"),
)
GRPC_DEPS = [
"@js_modules//google-protobuf",
"@js_modules//@grpc/grpc-js",
]

View File

@ -1,4 +1,4 @@
"""Generated definition of commonjs_grpc_compile."""
"""Generated definition of js_grpc_web_compile."""
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
load(
@ -11,8 +11,8 @@ load(
"proto_compile_impl",
)
# Create aspect for commonjs_grpc_compile
commonjs_grpc_compile_aspect = aspect(
# Create aspect for js_grpc_web_compile
js_grpc_web_compile_aspect = aspect(
implementation = proto_compile_aspect_impl,
provides = [ProtoLibraryAspectNodeInfo],
attr_aspects = ["deps"],
@ -22,12 +22,13 @@ commonjs_grpc_compile_aspect = aspect(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//grpc-web:commonjs_plugin"),
Label("//js:js_plugin"),
Label("//js:grpc_web_js_plugin"),
],
),
_prefix = attr.string(
doc = "String used to disambiguate aspects when generating outputs",
default = "commonjs_grpc_compile_aspect",
default = "js_grpc_web_compile_aspect",
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
@ -41,20 +42,21 @@ _rule = rule(
protos = attr.label_list(
mandatory = False, # TODO: set to true in 4.0.0 when deps removed below
providers = [ProtoInfo, ProtoLibraryAspectNodeInfo],
aspects = [commonjs_grpc_compile_aspect],
aspects = [js_grpc_web_compile_aspect],
doc = "List of labels that provide a ProtoInfo (such as rules_proto proto_library)",
),
deps = attr.label_list(
mandatory = False,
providers = [ProtoInfo, ProtoLibraryAspectNodeInfo],
aspects = [commonjs_grpc_compile_aspect],
aspects = [js_grpc_web_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//grpc-web:commonjs_plugin"),
Label("//js:js_plugin"),
Label("//js:grpc_web_js_plugin"),
],
),
),
@ -62,7 +64,7 @@ _rule = rule(
)
# Create macro for converting attrs and passing to compile
def commonjs_grpc_compile(**kwargs):
def js_grpc_web_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
**kwargs

View File

@ -0,0 +1,32 @@
"""Generated definition of js_grpc_web_library."""
load("//js:js_grpc_web_compile.bzl", "js_grpc_web_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
def js_grpc_web_library(**kwargs):
# Compile protos
name_pb = kwargs.get("name") + "_pb"
js_grpc_web_compile(
name = name_pb,
**{
k: v
for (k, v) in kwargs.items()
if k in ["protos" if "protos" in kwargs else "deps"] + proto_compile_attrs.keys()
} # Forward args
)
# Create js library
js_library(
name = kwargs.get("name"),
srcs = [name_pb],
deps = GRPC_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),
package_name = kwargs.get("name"),
visibility = kwargs.get("visibility"),
tags = kwargs.get("tags"),
)
GRPC_DEPS = [
"@js_modules//google-protobuf",
"@js_modules//grpc-web",
]

View File

@ -5,7 +5,31 @@ load(
"build_bazel_rules_nodejs",
"rules_proto_grpc_repos",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
def js_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
build_bazel_rules_nodejs(**kwargs)
# gRPC-Web plugin
grpc_web_version = "1.2.1" # When updating, also update in package.json and vice-versa
http_file(
name = "grpc_web_plugin_darwin",
executable = True,
urls = ["https://github.com/grpc/grpc-web/releases/download/{}/protoc-gen-grpc-web-{}-darwin-x86_64".format(grpc_web_version, grpc_web_version)],
sha256 = "81bb5d4d3ae0340568fd0739402c052f32476dd520b44355e5032b556a3bc0da",
)
http_file(
name = "grpc_web_plugin_linux",
executable = True,
urls = ["https://github.com/grpc/grpc-web/releases/download/{}/protoc-gen-grpc-web-{}-linux-x86_64".format(grpc_web_version, grpc_web_version)],
sha256 = "6ce1625db7902d38d38d83690ec578c182e9cf2abaeb58d3fba1dae0c299c597",
)
http_file(
name = "grpc_web_plugin_windows",
executable = True,
urls = ["https://github.com/grpc/grpc-web/releases/download/{}/protoc-gen-grpc-web-{}-windows-x86_64".format(grpc_web_version, grpc_web_version)],
sha256 = "5886b4c9886dfdbfd1c7c2f26a15c396c6662b9f1acf9b6d8efbd490bc3736db",
)

View File

@ -3,6 +3,7 @@
"@grpc/grpc-js": "1.2.6",
"google-protobuf": "3.14.0",
"grpc-tools": "1.10.0",
"grpc-web": "1.2.1",
"ts-protoc-gen": "0.14.0"
}
}

View File

@ -258,6 +258,11 @@ grpc-tools@1.10.0:
dependencies:
node-pre-gyp "^0.15.0"
grpc-web@1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/grpc-web/-/grpc-web-1.2.1.tgz#860051d705bf5baa7b81fcbd14030060bf16b7b9"
integrity sha512-ibBaJPzfMVuLPgaST9w0kZl60s+SnkPBQp6QKdpEr85tpc1gXW2QDqSne9xiyiym0logDfdUSm4aX5h9YBA2mw==
gtoken@^5.0.4:
version "5.1.0"
resolved "https://registry.yarnpkg.com/gtoken/-/gtoken-5.1.0.tgz#4ba8d2fc9a8459098f76e7e8fd7beaa39fda9fe4"

View File

@ -141,15 +141,6 @@ VERSIONS = {
"sha256": "d3196737b591055679a676aca99610ccf640fdfe6bad0aa756b0725cab0d8c12",
},
# gRPC web
"com_github_grpc_grpc_web": {
"type": "github",
"org": "grpc",
"repo": "grpc-web",
"ref": "1.2.1",
"sha256": "23cf98fbcb69743b8ba036728b56dfafb9e16b887a9735c12eafa7669862ec7b",
},
# Java
"io_grpc_grpc_java": {
"type": "github",
@ -471,12 +462,6 @@ def bazel_gazelle(**kwargs):
def grpc_ecosystem_grpc_gateway(**kwargs):
_generic_dependency("grpc_ecosystem_grpc_gateway", **kwargs)
#
# gRPC web
#
def com_github_grpc_grpc_web(**kwargs):
_generic_dependency("com_github_grpc_grpc_web", **kwargs)
#
# Java
#

View File

@ -35,7 +35,6 @@
- [D](/d/README.md)
- [Go](/go/README.md)
- [grpc-gateway](/grpc-gateway/README.md)
- [gRPC-Web](/grpc-web/README.md)
- [Java](/java/README.md)
- [JavaScript](/js/README.md)
- [Objective-C](/objc/README.md)

View File

@ -1,122 +0,0 @@
package main
var grpcWebWorkspaceTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:repositories.bzl", rules_proto_grpc_grpc_web_repos = "grpc_web_repos")
rules_proto_grpc_grpc_web_repos()
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
rules_closure_dependencies(
omit_com_google_protobuf = True,
)
rules_closure_toolchains()`)
var grpcWebGrpcLibraryRuleTemplate = mustTemplate(`load("//{{ .Lang.Dir }}:closure_grpc_compile.bzl", "closure_grpc_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("//closure:closure_proto_compile.bzl", "closure_proto_compile")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
def {{ .Rule.Name }}(**kwargs): # buildifier: disable=function-docstring
# Compile protos
name_pb = kwargs.get("name") + "_pb"
name_pb_grpc = kwargs.get("name") + "_pb_grpc"
closure_proto_compile(
name = name_pb,
{{ .Common.ArgsForwardingSnippet }}
)
closure_grpc_compile(
name = name_pb_grpc,
{{ .Common.ArgsForwardingSnippet }}
)
# Create closure library
closure_js_library(
name = kwargs.get("name"),
srcs = [name_pb, name_pb_grpc],
deps = GRPC_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),
suppress = [
"JSC_LATE_PROVIDE_ERROR",
"JSC_UNDEFINED_VARIABLE",
"JSC_IMPLICITLY_NULLABLE_JSDOC",
"JSC_STRICT_INEXISTENT_PROPERTY",
"JSC_POSSIBLE_INEXISTENT_PROPERTY",
"JSC_UNRECOGNIZED_TYPE_ERROR",
"JSC_UNUSED_PRIVATE_PROPERTY",
"JSC_EXTRA_REQUIRE_WARNING",
"JSC_INVALID_INTERFACE_MEMBER_DECLARATION",
"JSC_TYPE_MISMATCH",
"CR_NOT_PROVIDED",
],
visibility = kwargs.get("visibility"),
tags = kwargs.get("tags"),
)
GRPC_DEPS = [
"@com_github_grpc_grpc_web//javascript/net/grpc/web:abstractclientbase",
"@com_github_grpc_grpc_web//javascript/net/grpc/web:clientreadablestream",
"@com_github_grpc_grpc_web//javascript/net/grpc/web:grpcwebclientbase",
"@com_github_grpc_grpc_web//javascript/net/grpc/web:error",
"@io_bazel_rules_closure//closure/library",
"@io_bazel_rules_closure//closure/protobuf:jspb",
]`)
func makeGrpcWeb() *Language {
return &Language{
Dir: "grpc-web",
Name: "grpc-web",
DisplayName: "gRPC-Web",
Rules: []*Rule{
&Rule{
Name: "closure_grpc_compile",
Kind: "grpc",
Implementation: aspectRuleTemplate,
Plugins: []string{"//grpc-web:closure_plugin"},
WorkspaceExample: grpcWebWorkspaceTemplate,
BuildExample: grpcCompileExampleTemplate,
Doc: "Generates Closure *.js protobuf+gRPC files",
Attrs: compileRuleAttrs,
},
&Rule{
Name: "commonjs_grpc_compile",
Kind: "grpc",
Implementation: aspectRuleTemplate,
Plugins: []string{"//grpc-web:commonjs_plugin"},
WorkspaceExample: grpcWebWorkspaceTemplate,
BuildExample: grpcCompileExampleTemplate,
Doc: "Generates CommonJS *.js protobuf+gRPC files",
Attrs: compileRuleAttrs,
},
&Rule{
Name: "commonjs_dts_grpc_compile",
Kind: "grpc",
Implementation: aspectRuleTemplate,
Plugins: []string{"//grpc-web:commonjs_dts_plugin"},
WorkspaceExample: grpcWebWorkspaceTemplate,
BuildExample: grpcCompileExampleTemplate,
Doc: "Generates commonjs_dts *.js protobuf+gRPC files",
Attrs: compileRuleAttrs,
},
&Rule{
Name: "ts_grpc_compile",
Kind: "grpc",
Implementation: aspectRuleTemplate,
Plugins: []string{"//grpc-web:ts_plugin"},
WorkspaceExample: grpcWebWorkspaceTemplate,
BuildExample: grpcCompileExampleTemplate,
Doc: "Generates CommonJS *.ts protobuf+gRPC files",
Attrs: compileRuleAttrs,
},
&Rule{
Name: "closure_grpc_library",
Kind: "grpc",
Implementation: grpcWebGrpcLibraryRuleTemplate,
WorkspaceExample: grpcWebWorkspaceTemplate,
BuildExample: grpcLibraryExampleTemplate,
Doc: "Generates protobuf closure library *.js files",
Attrs: libraryRuleAttrs,
},
},
}
}

View File

@ -1,6 +1,6 @@
package main
var nodeWorkspaceTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:repositories.bzl", rules_proto_grpc_{{ .Lang.Name }}_repos = "{{ .Lang.Name }}_repos")
var jsWorkspaceTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:repositories.bzl", rules_proto_grpc_{{ .Lang.Name }}_repos = "{{ .Lang.Name }}_repos")
rules_proto_grpc_{{ .Lang.Name }}_repos()
@ -12,7 +12,7 @@ yarn_install(
yarn_lock = "@rules_proto_grpc//js:requirements/yarn.lock",
)`)
var nodeProtoLibraryRuleTemplate = mustTemplate(`load("//{{ .Lang.Dir }}:{{ .Lang.Name }}_{{ .Rule.Kind }}_compile.bzl", "{{ .Lang.Name }}_{{ .Rule.Kind }}_compile")
var jsProtoLibraryRuleTemplate = mustTemplate(`load("//{{ .Lang.Dir }}:{{ .Lang.Name }}_{{ .Rule.Kind }}_compile.bzl", "{{ .Lang.Name }}_{{ .Rule.Kind }}_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
@ -38,14 +38,14 @@ PROTO_DEPS = [
"@js_modules//google-protobuf",
]`)
var nodeGrpcLibraryRuleTemplate = mustTemplate(`load("//{{ .Lang.Dir }}:nodejs_{{ .Rule.Kind }}_compile.bzl", "nodejs_{{ .Rule.Kind }}_compile")
var nodeGrpcLibraryRuleTemplate = mustTemplate(`load("//{{ .Lang.Dir }}:js_grpc_node_compile.bzl", "js_grpc_node_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
def {{ .Rule.Name }}(**kwargs):
# Compile protos
name_pb = kwargs.get("name") + "_pb"
nodejs_{{ .Rule.Kind }}_compile(
js_grpc_node_compile(
name = name_pb,
{{ .Common.ArgsForwardingSnippet }}
)
@ -65,16 +65,45 @@ GRPC_DEPS = [
"@js_modules//@grpc/grpc-js",
]`)
var jsGrpcWebLibraryRuleTemplate = mustTemplate(`load("//{{ .Lang.Dir }}:js_grpc_web_compile.bzl", "js_grpc_web_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
def {{ .Rule.Name }}(**kwargs):
# Compile protos
name_pb = kwargs.get("name") + "_pb"
js_grpc_web_compile(
name = name_pb,
{{ .Common.ArgsForwardingSnippet }}
)
# Create {{ .Lang.Name }} library
js_library(
name = kwargs.get("name"),
srcs = [name_pb],
deps = GRPC_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),
package_name = kwargs.get("name"),
visibility = kwargs.get("visibility"),
tags = kwargs.get("tags"),
)
GRPC_DEPS = [
"@js_modules//google-protobuf",
"@js_modules//grpc-web",
]`)
func makeJavaScript() *Language {
return &Language{
Dir: "js",
Name: "js",
DisplayName: "JavaScript",
Notes: mustTemplate("Rules for generating JavaScript protobuf and gRPC `.js` and `.d.ts` files using standard Protocol Buffers and gRPC."),
Notes: mustTemplate("Rules for generating JavaScript protobuf, gRPC-node and gRPC-Web `.js` and `.d.ts` files using standard Protocol Buffers and gRPC."),
Flags: commonLangFlags,
Aliases: map[string]string{
"nodejs_proto_compile": "js_proto_compile",
"nodejs_proto_library": "js_proto_library",
"nodejs_grpc_compile": "js_grpc_node_compile",
"nodejs_grpc_library": "js_grpc_node_library",
},
Rules: []*Rule{
&Rule{
@ -82,37 +111,56 @@ func makeJavaScript() *Language {
Kind: "proto",
Implementation: aspectRuleTemplate,
Plugins: []string{"//js:js_plugin", "//js:ts_plugin"},
WorkspaceExample: nodeWorkspaceTemplate,
WorkspaceExample: jsWorkspaceTemplate,
BuildExample: protoCompileExampleTemplate,
Doc: "Generates JavaScript protobuf `.js` and `.d.ts` artifacts",
Attrs: compileRuleAttrs,
},
&Rule{
Name: "nodejs_grpc_compile",
Name: "js_grpc_node_compile",
Kind: "grpc",
Implementation: aspectRuleTemplate,
Plugins: []string{"//js:js_plugin", "//js:grpc_node_plugin", "//js:grpc_node_ts_plugin"}, // Don't need ts_plugin here, as grpc_node_ts_plugin will do both proto and grpc
WorkspaceExample: nodeWorkspaceTemplate,
WorkspaceExample: jsWorkspaceTemplate,
BuildExample: grpcCompileExampleTemplate,
Doc: "Generates JavaScript protobuf + Node.js gRPC `.js` and `.d.ts` artifacts",
Doc: "Generates JavaScript protobuf + gRPC-node `.js` and `.d.ts` artifacts",
Attrs: compileRuleAttrs,
},
&Rule{
Name: "js_grpc_web_compile",
Kind: "grpc",
Implementation: aspectRuleTemplate,
Plugins: []string{"//js:js_plugin", "//js:grpc_web_js_plugin"},
WorkspaceExample: jsWorkspaceTemplate,
BuildExample: grpcCompileExampleTemplate,
Doc: "Generates JavaScript protobuf + gRPC-Web `.js` and `.d.ts` artifacts",
Attrs: compileRuleAttrs,
},
&Rule{
Name: "js_proto_library",
Kind: "proto",
Implementation: nodeProtoLibraryRuleTemplate,
WorkspaceExample: nodeWorkspaceTemplate,
Implementation: jsProtoLibraryRuleTemplate,
WorkspaceExample: jsWorkspaceTemplate,
BuildExample: protoLibraryExampleTemplate,
Doc: "Generates a JavaScript protobuf library using `js_library` from `rules_nodejs`",
Attrs: libraryRuleAttrs,
},
&Rule{
Name: "nodejs_grpc_library",
Name: "js_grpc_node_library",
Kind: "grpc",
Implementation: nodeGrpcLibraryRuleTemplate,
WorkspaceExample: nodeWorkspaceTemplate,
WorkspaceExample: jsWorkspaceTemplate,
BuildExample: grpcLibraryExampleTemplate,
Doc: "Generates a Node.js protobuf+gRPC library using `js_library` from `rules_nodejs`",
Doc: "Generates a Node.js protobuf + gRPC-node library using `js_library` from `rules_nodejs`",
Attrs: libraryRuleAttrs,
},
&Rule{
Name: "js_grpc_web_library",
Kind: "grpc",
Implementation: jsGrpcWebLibraryRuleTemplate,
WorkspaceExample: jsWorkspaceTemplate,
BuildExample: protoLibraryExampleTemplate,
Doc: "Generates a JavaScript protobuf + gRPC-Web library using `js_library` from `rules_nodejs`",
Attrs: libraryRuleAttrs,
},
},

View File

@ -98,7 +98,6 @@ func action(c *cli.Context) error {
makeD(),
makeGo(),
makeGrpcGateway(),
makeGrpcWeb(),
makeJava(),
makeJavaScript(),
makeObjc(),