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