Allow to run cpp tests under grpc/tests/ using bazel. (#6040)

This is the first step to upgrade grpc dependency to the latest version.

- Patch protobuf 3.6.1. and grpc 1.15.1 to fix build errors when using the latest Bazel version (3.4.1).
- Add grpc/tests:grpc_test. One can kick off tests in Bazel by calling `bazel test grpc/tests/...`.
- Add missing build targets in tests/BUILD in order to support grpc/tests/BUILD
This commit is contained in:
Shengzhe
2020-07-21 11:08:01 -07:00
committed by GitHub
parent 6d0aae73cd
commit c8fa0afdfc
11 changed files with 166 additions and 6 deletions

View File

@@ -0,0 +1,48 @@
diff --git a/bazel/cc_grpc_library.bzl b/bazel/cc_grpc_library.bzl
index 3288565714..6bfcd653f5 100644
--- a/bazel/cc_grpc_library.bzl
+++ b/bazel/cc_grpc_library.bzl
@@ -1,6 +1,6 @@
"""Generates and compiles C++ grpc stubs from proto_library rules."""
-load("//:bazel/generate_cc.bzl", "generate_cc")
+load("//bazel:generate_cc.bzl", "generate_cc")
def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, generate_mocks = False, use_external = False, **kwargs):
"""Generates C++ grpc classes from a .proto file.
diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl
index ae747aa42c..2f14071f92 100644
--- a/bazel/generate_cc.bzl
+++ b/bazel/generate_cc.bzl
@@ -83,7 +83,7 @@ _generate_cc = rule(
attrs = {
"srcs": attr.label_list(
mandatory = True,
- non_empty = True,
+ allow_empty = False,
providers = ["proto"],
),
"plugin": attr.label(
diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl
index 73147bf3ac..e8c392aa93 100644
--- a/bazel/grpc_build_system.bzl
+++ b/bazel/grpc_build_system.bzl
@@ -24,6 +24,9 @@
#
# The set of pollers to test against if a test exercises polling
+
+load("//bazel:cc_grpc_library.bzl", "cc_grpc_library")
+
POLLERS = ['epollex', 'epollsig', 'epoll1', 'poll', 'poll-cv']
def if_not_windows(a):
@@ -95,8 +98,6 @@ def grpc_proto_plugin(name, srcs = [], deps = []):
deps = deps,
)
-load("//:bazel/cc_grpc_library.bzl", "cc_grpc_library")
-
def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = False,
has_services = True, use_external = False, generate_mocks = False):
cc_grpc_library(

View File

@@ -0,0 +1,24 @@
diff --git a/protobuf.bzl b/protobuf.bzl
index 78f19c621..3b6d183b9 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -130,7 +130,7 @@ proto_gen = rule(
"protoc": attr.label(
cfg = "host",
executable = True,
- single_file = True,
+ allow_single_file = True,
mandatory = True,
),
"plugin": attr.label(
@@ -266,8 +266,8 @@ def internal_gen_well_known_protos_java(srcs):
Args:
srcs: the well known protos
"""
- root = Label("%s//protobuf_java" % (REPOSITORY_NAME)).workspace_root
- pkg = PACKAGE_NAME + "/" if PACKAGE_NAME else ""
+ root = Label("%s//protobuf_java" % (native.repository_name())).workspace_root
+ pkg = native.package_name() + "/" if native.package_name() else ""
if root == "":
include = " -I%ssrc " % pkg
else: