mirror of https://github.com/grpc/grpc-web.git
[bazel] Update rules_closure + fix linter warnings
Working towards resolving #744, #575, #550, #700
This commit is contained in:
parent
16a54fa05a
commit
40cbb49772
12
WORKSPACE
12
WORKSPACE
|
@ -4,13 +4,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "io_bazel_rules_closure",
|
name = "io_bazel_rules_closure",
|
||||||
sha256 = "fecda06179906857ac79af6500124bf03fe1630fd1b3d4dcf6c65346b9c0725d",
|
sha256 = "d7a04263cf5b7af90f52d759da1e50c3cfe81c6cb16eec430af86e6bed248098",
|
||||||
strip_prefix = "rules_closure-03110588392d8c6c05b99c08a6f1c2121604ca27",
|
strip_prefix = "rules_closure-0e187366b658d1796d2580f8b7e1a8d7e7e1492d",
|
||||||
urls = [
|
urls = [
|
||||||
"https://github.com/bazelbuild/rules_closure/archive/03110588392d8c6c05b99c08a6f1c2121604ca27.zip",
|
"https://github.com/bazelbuild/rules_closure/archive/0e187366b658d1796d2580f8b7e1a8d7e7e1492d.zip",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories")
|
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
|
||||||
|
|
||||||
closure_repositories()
|
rules_closure_dependencies()
|
||||||
|
|
||||||
|
rules_closure_toolchains()
|
||||||
|
|
|
@ -2,19 +2,12 @@
|
||||||
# |closure_proto_library|, licensed under Apache 2.
|
# |closure_proto_library|, licensed under Apache 2.
|
||||||
# https://github.com/bazelbuild/rules_closure/blob/3555e5ba61fdcc17157dd833eaf7d19b313b1bca/closure/protobuf/closure_proto_library.bzl
|
# https://github.com/bazelbuild/rules_closure/blob/3555e5ba61fdcc17157dd833eaf7d19b313b1bca/closure/protobuf/closure_proto_library.bzl
|
||||||
|
|
||||||
load(
|
"""Starlark rules for using gRPC-Web with Bazel and `rules_closure`."""
|
||||||
"@io_bazel_rules_closure//closure/compiler:closure_js_library.bzl",
|
|
||||||
"create_closure_js_library",
|
load("@io_bazel_rules_closure//closure/compiler:closure_js_library.bzl", "create_closure_js_library")
|
||||||
)
|
load("@io_bazel_rules_closure//closure/private:defs.bzl", "CLOSURE_JS_TOOLCHAIN_ATTRS", "unfurl") # buildifier: disable=bzl-visibility
|
||||||
load(
|
load("@io_bazel_rules_closure//closure/protobuf:closure_proto_library.bzl", "closure_proto_aspect")
|
||||||
"@io_bazel_rules_closure//closure/private:defs.bzl",
|
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
|
||||||
"CLOSURE_JS_TOOLCHAIN_ATTRS",
|
|
||||||
"unfurl",
|
|
||||||
)
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_closure//closure/protobuf:closure_proto_library.bzl",
|
|
||||||
"closure_proto_aspect",
|
|
||||||
)
|
|
||||||
|
|
||||||
# This was borrowed from Rules Go, licensed under Apache 2.
|
# This was borrowed from Rules Go, licensed under Apache 2.
|
||||||
# https://github.com/bazelbuild/rules_go/blob/67f44035d84a352cffb9465159e199066ecb814c/proto/compiler.bzl#L72
|
# https://github.com/bazelbuild/rules_go/blob/67f44035d84a352cffb9465159e199066ecb814c/proto/compiler.bzl#L72
|
||||||
|
@ -109,41 +102,35 @@ def _closure_grpc_web_library_impl(ctx):
|
||||||
# TODO(yannic): Revisit this restriction.
|
# TODO(yannic): Revisit this restriction.
|
||||||
fail(_error_multiple_deps, "deps")
|
fail(_error_multiple_deps, "deps")
|
||||||
|
|
||||||
dep = ctx.attr.deps[0]
|
proto_info = ctx.attr.deps[0][ProtoInfo]
|
||||||
|
|
||||||
srcs = _generate_closure_grpc_web_srcs(
|
srcs = _generate_closure_grpc_web_srcs(
|
||||||
actions = ctx.actions,
|
actions = ctx.actions,
|
||||||
protoc = ctx.executable._protoc,
|
protoc = ctx.executable._protoc,
|
||||||
protoc_gen_grpc_web = ctx.executable._protoc_gen_grpc_web,
|
protoc_gen_grpc_web = ctx.executable._protoc_gen_grpc_web,
|
||||||
import_style = ctx.attr.import_style,
|
import_style = ctx.attr.import_style,
|
||||||
mode = ctx.attr.mode,
|
mode = ctx.attr.mode,
|
||||||
sources = dep[ProtoInfo].direct_sources,
|
sources = proto_info.direct_sources,
|
||||||
transitive_sources = dep[ProtoInfo].transitive_imports,
|
transitive_sources = proto_info.transitive_imports,
|
||||||
)
|
)
|
||||||
|
|
||||||
deps = unfurl(ctx.attr.deps, provider = "closure_js_library")
|
deps = unfurl(ctx.attr.deps, provider = "closure_js_library")
|
||||||
deps += [
|
deps.append(ctx.attr._runtime)
|
||||||
ctx.attr._grpc_web_abstractclientbase,
|
library = create_closure_js_library(
|
||||||
ctx.attr._grpc_web_clientreadablestream,
|
ctx = ctx,
|
||||||
ctx.attr._grpc_web_error,
|
srcs = srcs,
|
||||||
ctx.attr._grpc_web_grpcwebclientbase,
|
deps = deps,
|
||||||
]
|
|
||||||
|
|
||||||
suppress = [
|
suppress = [
|
||||||
"misplacedTypeAnnotation",
|
"misplacedTypeAnnotation",
|
||||||
"unusedPrivateMembers",
|
"unusedPrivateMembers",
|
||||||
"reportUnknownTypes",
|
"reportUnknownTypes",
|
||||||
"strictDependencies",
|
"strictDependencies",
|
||||||
"extraRequire",
|
"extraRequire",
|
||||||
]
|
],
|
||||||
|
|
||||||
library = create_closure_js_library(
|
|
||||||
ctx = ctx,
|
|
||||||
srcs = srcs,
|
|
||||||
deps = deps,
|
|
||||||
suppress = suppress,
|
|
||||||
lenient = False,
|
lenient = False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# `rules_closure` still uses the legacy provider syntax.
|
||||||
|
# buildifier: disable=rule-impl-return
|
||||||
return struct(
|
return struct(
|
||||||
exports = library.exports,
|
exports = library.exports,
|
||||||
closure_js_library = library.closure_js_library,
|
closure_js_library = library.closure_js_library,
|
||||||
|
@ -169,29 +156,24 @@ closure_grpc_web_library = rule(
|
||||||
values = ["grpcwebtext", "grpcweb"],
|
values = ["grpcwebtext", "grpcweb"],
|
||||||
),
|
),
|
||||||
|
|
||||||
# internal only
|
# Internal only.
|
||||||
# TODO(yannic): Convert to toolchain.
|
|
||||||
|
# TODO(yannic): Switch to using `proto_toolchain` after
|
||||||
|
# https://github.com/bazelbuild/rules_proto/pull/25 lands.
|
||||||
"_protoc": attr.label(
|
"_protoc": attr.label(
|
||||||
default = Label("@com_google_protobuf//:protoc"),
|
default = Label("@com_google_protobuf//:protoc"),
|
||||||
executable = True,
|
executable = True,
|
||||||
cfg = "host",
|
cfg = "host",
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# TODO(yannic): Create `grpc_web_toolchain`.
|
||||||
"_protoc_gen_grpc_web": attr.label(
|
"_protoc_gen_grpc_web": attr.label(
|
||||||
default = Label("//javascript/net/grpc/web:protoc-gen-grpc-web"),
|
default = Label("//javascript/net/grpc/web:protoc-gen-grpc-web"),
|
||||||
executable = True,
|
executable = True,
|
||||||
cfg = "host",
|
cfg = "host",
|
||||||
),
|
),
|
||||||
"_grpc_web_abstractclientbase": attr.label(
|
"_runtime": attr.label(
|
||||||
default = Label("//javascript/net/grpc/web:abstractclientbase"),
|
default = Label("//javascript/net/grpc/web:closure_grpcweb_runtime"),
|
||||||
),
|
|
||||||
"_grpc_web_clientreadablestream": attr.label(
|
|
||||||
default = Label("//javascript/net/grpc/web:clientreadablestream"),
|
|
||||||
),
|
|
||||||
"_grpc_web_error": attr.label(
|
|
||||||
default = Label("//javascript/net/grpc/web:error"),
|
|
||||||
),
|
|
||||||
"_grpc_web_grpcwebclientbase": attr.label(
|
|
||||||
default = Label("//javascript/net/grpc/web:grpcwebclientbase"),
|
|
||||||
),
|
),
|
||||||
}, **CLOSURE_JS_TOOLCHAIN_ATTRS),
|
}, **CLOSURE_JS_TOOLCHAIN_ATTRS),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,24 +1,35 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library", "closure_js_test")
|
||||||
|
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||||
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary")
|
|
||||||
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
|
|
||||||
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_test")
|
|
||||||
|
|
||||||
cc_binary(
|
cc_binary(
|
||||||
name = "protoc-gen-grpc-web",
|
name = "protoc-gen-grpc-web",
|
||||||
srcs = [
|
srcs = [
|
||||||
"grpc_generator.cc",
|
"grpc_generator.cc",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"@com_google_protobuf//:protoc_lib",
|
"@com_google_protobuf//:protoc_lib",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Runtime for `import_style=closure` and `mode={grpcweb,grpcwebtext}`
|
||||||
|
closure_js_library(
|
||||||
|
name = "closure_grpcweb_runtime",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
exports = [
|
||||||
|
":abstractclientbase",
|
||||||
|
":clientreadablestream",
|
||||||
|
":error",
|
||||||
|
":grpcwebclientbase",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
closure_js_library(
|
closure_js_library(
|
||||||
name = "abstractclientbase",
|
name = "abstractclientbase",
|
||||||
srcs = [
|
srcs = [
|
||||||
"abstractclientbase.js",
|
"abstractclientbase.js",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
":clientreadablestream",
|
":clientreadablestream",
|
||||||
":error",
|
":error",
|
||||||
|
@ -31,6 +42,7 @@ closure_js_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"clientreadablestream.js",
|
"clientreadablestream.js",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
closure_js_library(
|
closure_js_library(
|
||||||
|
@ -38,6 +50,7 @@ closure_js_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"error.js",
|
"error.js",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
":metadata",
|
":metadata",
|
||||||
],
|
],
|
||||||
|
@ -48,6 +61,7 @@ closure_js_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"generictransportinterface.js",
|
"generictransportinterface.js",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"@io_bazel_rules_closure//closure/library/net:xhrio",
|
"@io_bazel_rules_closure//closure/library/net:xhrio",
|
||||||
"@io_bazel_rules_closure//closure/library/net/streams:nodereadablestream",
|
"@io_bazel_rules_closure//closure/library/net/streams:nodereadablestream",
|
||||||
|
@ -63,6 +77,7 @@ closure_js_library(
|
||||||
"checkTypes",
|
"checkTypes",
|
||||||
"reportUnknownTypes",
|
"reportUnknownTypes",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
":abstractclientbase",
|
":abstractclientbase",
|
||||||
":grpcwebclientreadablestream",
|
":grpcwebclientreadablestream",
|
||||||
|
@ -81,6 +96,7 @@ closure_js_library(
|
||||||
suppress = [
|
suppress = [
|
||||||
"reportUnknownTypes",
|
"reportUnknownTypes",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
":clientreadablestream",
|
":clientreadablestream",
|
||||||
":generictransportinterface",
|
":generictransportinterface",
|
||||||
|
@ -105,6 +121,7 @@ closure_js_library(
|
||||||
suppress = [
|
suppress = [
|
||||||
"reportUnknownTypes",
|
"reportUnknownTypes",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"@io_bazel_rules_closure//closure/library/asserts",
|
"@io_bazel_rules_closure//closure/library/asserts",
|
||||||
"@io_bazel_rules_closure//closure/library/net/streams:streamparser",
|
"@io_bazel_rules_closure//closure/library/net/streams:streamparser",
|
||||||
|
@ -116,6 +133,7 @@ closure_js_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"metadata.js",
|
"metadata.js",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
closure_js_library(
|
closure_js_library(
|
||||||
|
@ -123,6 +141,7 @@ closure_js_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"methoddescriptor.js",
|
"methoddescriptor.js",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
":methodtype",
|
":methodtype",
|
||||||
],
|
],
|
||||||
|
@ -133,6 +152,7 @@ closure_js_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"methodtype.js",
|
"methodtype.js",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
closure_js_library(
|
closure_js_library(
|
||||||
|
@ -140,6 +160,7 @@ closure_js_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"status.js",
|
"status.js",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
closure_js_library(
|
closure_js_library(
|
||||||
|
@ -147,6 +168,7 @@ closure_js_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"statuscode.js",
|
"statuscode.js",
|
||||||
],
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
closure_js_test(
|
closure_js_test(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||||
load("//bazel:closure_grpc_web_library.bzl", "closure_grpc_web_library")
|
load("//bazel:closure_grpc_web_library.bzl", "closure_grpc_web_library")
|
||||||
|
|
||||||
proto_library(
|
proto_library(
|
||||||
|
|
|
@ -22,15 +22,11 @@ cd "${REPO_DIR}"
|
||||||
make clean
|
make clean
|
||||||
|
|
||||||
# Lint bazel files.
|
# Lint bazel files.
|
||||||
BUILDIFIER_VERSION=0.22.0
|
BUILDIFIER_VERSION=1.0.0
|
||||||
wget "https://github.com/bazelbuild/buildtools/releases/download/${BUILDIFIER_VERSION}/buildifier"
|
wget "https://github.com/bazelbuild/buildtools/releases/download/${BUILDIFIER_VERSION}/buildifier"
|
||||||
chmod +x "./buildifier"
|
chmod +x "./buildifier"
|
||||||
./buildifier -version
|
./buildifier -version
|
||||||
BAZEL_FILES=$(find "${REPO_DIR}" \
|
./buildifier --mode=check --lint=warn --warnings=all -r bazel javascript net
|
||||||
-not -path "${REPO_DIR}/.git/*" -and \
|
|
||||||
-not -path "${REPO_DIR}/third_party/*" -and \
|
|
||||||
\( -name "BUILD.bazel" -o -name "*.bzl" \))
|
|
||||||
./buildifier -mode check ${BAZEL_FILES[@]}
|
|
||||||
rm ./buildifier
|
rm ./buildifier
|
||||||
|
|
||||||
# These programs need to be already installed
|
# These programs need to be already installed
|
||||||
|
@ -45,7 +41,7 @@ done
|
||||||
docker-compose -f advanced.yml build
|
docker-compose -f advanced.yml build
|
||||||
|
|
||||||
# Run all bazel unit tests
|
# Run all bazel unit tests
|
||||||
BAZEL_VERSION=1.2.1
|
BAZEL_VERSION=2.2.0
|
||||||
wget https://github.com/bazelbuild/bazel/releases/download/"${BAZEL_VERSION}"/bazel-"${BAZEL_VERSION}"-installer-linux-x86_64.sh
|
wget https://github.com/bazelbuild/bazel/releases/download/"${BAZEL_VERSION}"/bazel-"${BAZEL_VERSION}"-installer-linux-x86_64.sh
|
||||||
chmod +x ./bazel-"${BAZEL_VERSION}"-installer-linux-x86_64.sh
|
chmod +x ./bazel-"${BAZEL_VERSION}"-installer-linux-x86_64.sh
|
||||||
./bazel-"${BAZEL_VERSION}"-installer-linux-x86_64.sh --user
|
./bazel-"${BAZEL_VERSION}"-installer-linux-x86_64.sh --user
|
||||||
|
|
Loading…
Reference in New Issue