Skip to content

Commit f328ac6

Browse files
committed
[bazel] Add fixes for --incompatible_load_proto_rules_from_bzl
Starting soon, Protobuf rules will require explicit load statements bazelbuild/bazel#8922
1 parent d555967 commit f328ac6

File tree

23 files changed

+66
-52
lines changed

23 files changed

+66
-52
lines changed

WORKSPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ workspace(name = "com_github_grpc_grpc")
22

33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44
load("//bazel:grpc_deps.bzl", "grpc_deps", "grpc_test_only_deps")
5+
load("//bazel:grpc_python_deps.bzl", "grpc_python_deps")
56
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
67

78
grpc_deps()
89

910
grpc_test_only_deps()
1011

12+
grpc_python_deps()
13+
1114
register_execution_platforms(
1215
"//third_party/toolchains:local",
1316
"//third_party/toolchains:local_large",

bazel/cc_grpc_library.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Generates and compiles C++ grpc stubs from proto_library rules."""
22

3+
load("@rules_proto//proto:defs.bzl", "proto_library")
34
load("//bazel:generate_cc.bzl", "generate_cc")
45
load("//bazel:protobuf.bzl", "well_known_proto_libs")
56

@@ -64,7 +65,7 @@ def cc_grpc_library(
6465
if well_known_protos:
6566
proto_deps += well_known_proto_libs()
6667

67-
native.proto_library(
68+
proto_library(
6869
name = proto_target,
6970
srcs = srcs,
7071
deps = proto_deps,

bazel/grpc_build_system.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def grpc_cc_library(
106106
testonly = testonly,
107107
linkopts = linkopts,
108108
includes = [
109-
"include",
109+
"include",
110110
"src/core/ext/upb-generated", # Once upb code-gen issue is resolved, remove this.
111111
],
112112
alwayslink = alwayslink,
@@ -181,7 +181,7 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
181181
"exec_compatible_with": exec_compatible_with,
182182
}
183183
if uses_polling:
184-
# the vanilla version of the test should run on platforms that only
184+
# the vanilla version of the test should run on platforms that only
185185
# support a single poller
186186
native.cc_test(
187187
name = name,
@@ -317,7 +317,7 @@ def grpc_objc_library(
317317
deps: dependencies
318318
visibility: visibility, default to public
319319
"""
320-
320+
321321
native.objc_library(
322322
name = name,
323323
hdrs = hdrs,
@@ -329,7 +329,7 @@ def grpc_objc_library(
329329
includes = includes,
330330
visibility = visibility,
331331
)
332-
332+
333333
def grpc_upb_proto_library(name, deps):
334334
upb_proto_library(name = name, deps = deps)
335335

bazel/grpc_deps.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def grpc_deps():
6161
name = "gtest",
6262
actual = "@com_github_google_googletest//:gtest",
6363
)
64-
64+
6565
native.bind(
6666
name = "benchmark",
6767
actual = "@com_github_google_benchmark//:benchmark",
@@ -117,9 +117,9 @@ def grpc_deps():
117117
if "com_google_protobuf" not in native.existing_rules():
118118
http_archive(
119119
name = "com_google_protobuf",
120-
sha256 = "416212e14481cff8fd4849b1c1c1200a7f34808a54377e22d7447efdf54ad758",
121-
strip_prefix = "protobuf-09745575a923640154bcf307fba8aedff47f240a",
122-
url = "https://github.com/google/protobuf/archive/09745575a923640154bcf307fba8aedff47f240a.tar.gz",
120+
sha256 = "758249b537abba2f21ebc2d02555bf080917f0f2f88f4cbe2903e0e28c4187ed",
121+
strip_prefix = "protobuf-3.10.0",
122+
url = "https://github.com/google/protobuf/archive/v3.10.0.tar.gz",
123123
)
124124

125125
if "com_github_google_googletest" not in native.existing_rules():

bazel/grpc_python_deps.bzl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44
load("@com_github_grpc_grpc//third_party/py:python_configure.bzl", "python_configure")
55

66
def grpc_python_deps():
7-
native.bind(
8-
name = "six",
9-
actual = "@six_archive//:six",
10-
)
11-
12-
# protobuf binds to the name "six", so we can't use it here.
13-
# See https://github.com/bazelbuild/bazel/issues/1952 for why bind is
14-
# horrible.
15-
if "six_archive" not in native.existing_rules():
7+
if "six" not in native.existing_rules():
168
http_archive(
17-
name = "six_archive",
18-
strip_prefix = "six-1.12.0",
9+
name = "six",
1910
build_file = "@com_github_grpc_grpc//third_party:six.BUILD",
2011
sha256 = "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73",
21-
urls = ["https://files.pythonhosted.org/packages/dd/bf/4138e7bfb757de47d1f4b6994648ec67a51efe58fa907c1e11e350cddfca/six-1.12.0.tar.gz"],
12+
urls = ["https://pypi.python.org/packages/source/s/six/six-1.12.0.tar.gz"],
2213
)
2314

2415
if "enum34" not in native.existing_rules():

src/objective-c/examples/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ licenses(["notice"]) # 3-clause BSD
1919
package(default_visibility = ["//visibility:public"])
2020

2121
load(
22-
"//src/objective-c:grpc_objc_internal_library.bzl",
22+
"//src/objective-c:grpc_objc_internal_library.bzl",
2323
"grpc_objc_examples_library",
2424
"local_objc_grpc_library",
2525
"proto_library_objc_wrapper",

src/objective-c/grpc_objc_internal_library.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# each change must be ported from one to the other.
2424
#
2525

26+
load("@rules_proto//proto:defs.bzl", "proto_library")
2627
load(
2728
"//bazel:generate_objc.bzl",
2829
"generate_objc",
@@ -39,7 +40,7 @@ def proto_library_objc_wrapper(
3940
"""proto_library for adding dependencies to google/protobuf protos
4041
use_well_known_protos - ignored in open source version
4142
"""
42-
native.proto_library(
43+
proto_library(
4344
name = name,
4445
srcs = srcs,
4546
deps = deps,

src/proto/grpc/channelz/BUILD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
licenses(["notice"]) # Apache v2
16-
15+
load("@rules_proto//proto:defs.bzl", "proto_library")
1716
load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package")
1817

18+
licenses(["notice"]) # Apache v2
19+
1920
grpc_package(name = "channelz", visibility = "public")
2021

2122
grpc_proto_library(

src/proto/grpc/core/BUILD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
licenses(["notice"]) # Apache v2
16-
15+
load("@rules_proto//proto:defs.bzl", "proto_library")
1716
load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package")
1817

18+
licenses(["notice"]) # Apache v2
19+
1920
grpc_package(name = "core", visibility = "public")
2021

2122
grpc_proto_library(

src/proto/grpc/gcp/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@rules_proto//proto:defs.bzl", "proto_library")
16+
1517
licenses(["notice"]) # Apache v2
1618

1719
proto_library(

0 commit comments

Comments
 (0)