Upgrading to latest gRPC and io_bazel_rules_go
diff --git a/WORKSPACE b/WORKSPACE
index 2d963f2..93da064 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -2,55 +2,51 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-load("//:repository_rules.bzl", "switched_rules_by_language")
-switched_rules_by_language(
- name = "bazel_remote_apis_imports",
- go = True,
- java = True,
- cc = True,
-)
-
-# Needed for protobuf.
+# Pull in go rules, which we need selectively pull in Go dependencies.
http_archive(
- name = "bazel_skylib",
- # Commit f83cb8dd6f5658bc574ccd873e25197055265d1c of 2018-11-26
- sha256 = "ba5d15ca230efca96320085d8e4d58da826d1f81b444ef8afccd8b23e0799b52",
- strip_prefix = "bazel-skylib-f83cb8dd6f5658bc574ccd873e25197055265d1c",
+ name = "io_bazel_rules_go",
+ sha256 = "513c12397db1bc9aa46dd62f02dd94b49a9b5d17444d49b5a04c5a89f3053c1c",
urls = [
- "https://github.com/bazelbuild/bazel-skylib/archive/f83cb8dd6f5658bc574ccd873e25197055265d1c.tar.gz",
+ "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/v0.19.5/rules_go-v0.19.5.tar.gz",
+ "https://github.com/bazelbuild/rules_go/releases/download/v0.19.5/rules_go-v0.19.5.tar.gz",
],
)
-# Needed for "well-known protos" and protoc.
+# Gazelle, which we need in order to selectively pull in Gazelle dependencies for Go.
http_archive(
- name = "com_google_protobuf",
- sha256 = "3e933375ecc58d01e52705479b82f155aea2d02cc55d833f8773213e74f88363",
- strip_prefix = "protobuf-3.7.0",
- urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v3.7.0/protobuf-all-3.7.0.tar.gz"],
+ name = "bazel_gazelle",
+ sha256 = "7fc87f4170011201b1690326e8c16c5d802836e3a0d617d8f75c3af2b23180c4",
+ urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.18.2/bazel-gazelle-0.18.2.tar.gz"],
)
-# Needed for the googleapis protos.
-http_archive(
- name = "googleapis",
- build_file = "BUILD.googleapis",
- sha256 = "7b6ea252f0b8fb5cd722f45feb83e115b689909bbb6a393a873b6cbad4ceae1d",
- strip_prefix = "googleapis-143084a2624b6591ee1f9d23e7f5241856642f4d",
- urls = ["https://github.com/googleapis/googleapis/archive/143084a2624b6591ee1f9d23e7f5241856642f4d.zip"],
+# Needed for protobuf.
+load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
+
+git_repository(
+ name = "com_google_protobuf",
+ commit = "09745575a923640154bcf307fba8aedff47f240a",
+ remote = "https://github.com/protocolbuffers/protobuf",
+ shallow_since = "1558721209 -0700",
)
+load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
+
+protobuf_deps()
+
# Needed for C++ gRPC.
http_archive(
name = "com_github_grpc_grpc",
- strip_prefix = "grpc-1.21.0",
+ sha256 = "11ac793c562143d52fd440f6549588712badc79211cdc8c509b183cb69bddad8",
+ strip_prefix = "grpc-1.22.0",
urls = [
- "https://github.com/grpc/grpc/archive/v1.21.0.tar.gz",
- "https://mirror.bazel.build/github.com/grpc/grpc/archive/v1.21.0.tar.gz",
+ "https://github.com/grpc/grpc/archive/v1.22.0.tar.gz",
+ "https://mirror.bazel.build/github.com/grpc/grpc/archive/v1.22.0.tar.gz",
],
- sha256 = "8da7f32cc8978010d2060d740362748441b81a34e5425e108596d3fcd63a97f2",
)
# Pull in all gRPC dependencies.
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
+
grpc_deps()
bind(
@@ -63,27 +59,20 @@
actual = "@com_github_grpc_grpc//:grpc++",
)
-# We have to import zlib directly ourselves, because protobuf_deps.bzl isn't
-# part of the protobuf release yet
-# (https://github.com/protocolbuffers/protobuf/issues/5918). This should be
-# fixed in 3.8.0.
-http_archive(
- name = "net_zlib",
- build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
- sha256 = "6d4d6640ca3121620995ee255945161821218752b551a1a180f4215f7d124d45",
- strip_prefix = "zlib-1.2.11",
- urls = ["https://zlib.net/zlib-1.2.11.tar.gz"],
+load("//:repository_rules.bzl", "switched_rules_by_language")
+
+switched_rules_by_language(
+ name = "bazel_remote_apis_imports",
+ cc = True,
+ go = True,
+ java = True,
)
-# Pull in go rules.
+# Needed for the googleapis protos.
http_archive(
- name = "io_bazel_rules_go",
- urls = [
- "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz",
- "https://github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz",
- ],
- sha256 = "f04d2373bcaf8aa09bccb08a98a57e721306c8f6043a2a0ee610fd6853dcde3d",
+ name = "googleapis",
+ build_file = "BUILD.googleapis",
+ sha256 = "7b6ea252f0b8fb5cd722f45feb83e115b689909bbb6a393a873b6cbad4ceae1d",
+ strip_prefix = "googleapis-143084a2624b6591ee1f9d23e7f5241856642f4d",
+ urls = ["https://github.com/googleapis/googleapis/archive/143084a2624b6591ee1f9d23e7f5241856642f4d.zip"],
)
-load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")
-go_rules_dependencies()
-go_register_toolchains()
diff --git a/remote_apis_deps.bzl b/remote_apis_deps.bzl
new file mode 100644
index 0000000..a4b3c24
--- /dev/null
+++ b/remote_apis_deps.bzl
@@ -0,0 +1,38 @@
+"""Load dependencies needed to depend on the RE API repo."""
+
+load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
+load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
+
+def remote_apis_go_deps():
+ """Load dependencies needed to depend on RE API for Go"""
+ go_rules_dependencies()
+ go_register_toolchains()
+ gazelle_dependencies()
+ if "com_github_golang_protobuf" not in native.existing_rules():
+ go_repository(
+ name = "com_github_golang_protobuf",
+ importpath = "github.com/golang/protobuf",
+ tag = "v1.3.2",
+ )
+ if "org_golang_google_grpc" not in native.existing_rules():
+ go_repository(
+ name = "org_golang_google_grpc",
+ build_file_proto_mode = "disable",
+ importpath = "google.golang.org/grpc",
+ sum = "h1:J0UbZOIrCAl+fpTOf8YLs4dJo8L/owV4LYVtAXQoPkw=",
+ version = "v1.22.0",
+ )
+ if "org_golang_x_net" not in native.existing_rules():
+ go_repository(
+ name = "org_golang_x_net",
+ importpath = "golang.org/x/net",
+ sum = "h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=",
+ version = "v0.0.0-20190311183353-d8887717615a",
+ )
+ if "org_golang_x_text" not in native.existing_rules():
+ go_repository(
+ name = "org_golang_x_text",
+ importpath = "golang.org/x/text",
+ sum = "h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=",
+ version = "v0.3.0",
+ )
diff --git a/repository_rules.bzl b/repository_rules.bzl
index 6901d50..f569ee8 100644
--- a/repository_rules.bzl
+++ b/repository_rules.bzl
@@ -6,6 +6,8 @@
https://github.com/googleapis/googleapis/blob/master/repository_rules.bzl
"""
+load("//:remote_apis_deps.bzl", "remote_apis_go_deps")
+
def _switched_rules_impl(ctx):
disabled_rule_script = """
def {rule_name}(**kwargs):
@@ -116,6 +118,8 @@
name = name,
rules = rules,
)
+ if go:
+ remote_apis_go_deps()
def _switch(enabled, enabled_value):
return enabled_value if enabled else ""