From 5011420f160b91129a7baebe21df9444a07896a6 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 5 Nov 2024 16:51:31 -0800 Subject: [PATCH] [proto] revert to old-style BUILD rules for channelz and reflection PiperOrigin-RevId: 693522142 --- BUILD | 6 ++--- bazel/cc_grpc_library.bzl | 8 +++--- src/proto/grpc/channelz/BUILD | 25 +++++-------------- src/proto/grpc/reflection/v1/BUILD | 19 ++++---------- src/proto/grpc/reflection/v1alpha/BUILD | 19 ++++---------- src/proto/grpc/testing/BUILD | 2 +- .../grpc_channelz/v1/BUILD.bazel | 4 +-- .../grpc_reflection/v1alpha/BUILD.bazel | 4 +-- test/cpp/end2end/BUILD | 2 +- test/cpp/util/BUILD | 12 ++++----- 10 files changed, 35 insertions(+), 66 deletions(-) diff --git a/BUILD b/BUILD index 0be13c0df87..5bd39faec64 100644 --- a/BUILD +++ b/BUILD @@ -2526,8 +2526,8 @@ grpc_cc_library( "config_vars", "grpc++", "grpc++_config_proto", - "//src/proto/grpc/reflection/v1:reflection_cc_grpc", - "//src/proto/grpc/reflection/v1alpha:reflection_cc_grpc", + "//src/proto/grpc/reflection/v1:reflection_proto", + "//src/proto/grpc/reflection/v1alpha:reflection_proto", ], alwayslink = 1, ) @@ -2635,7 +2635,7 @@ grpc_cc_library( "grpc", "grpc++", "grpc++_config_proto", - "//src/proto/grpc/channelz:channelz_cc_grpc", + "//src/proto/grpc/channelz:channelz_proto", ], alwayslink = 1, ) diff --git a/bazel/cc_grpc_library.bzl b/bazel/cc_grpc_library.bzl index 55ea11cd53f..f23ac0d5b65 100644 --- a/bazel/cc_grpc_library.bzl +++ b/bazel/cc_grpc_library.bzl @@ -70,11 +70,11 @@ def cc_grpc_library( proto_targets = [] if not grpc_only: - proto_target = "_" + name + "_only" - cc_proto_target = name if proto_only else "_" + name + "_cc_proto" + proto_target = name + "_only" + cc_proto_target = name if proto_only else name + "_cc_proto" - proto_deps = ["_" + dep + "_only" for dep in deps if dep.find(":") == -1] - proto_deps += [dep.split(":")[0] + ":" + "_" + dep.split(":")[1] + "_only" for dep in deps if dep.find(":") != -1 and dep.find("com_google_googleapis") == -1] + proto_deps = [dep + "_only" for dep in deps if dep.find(":") == -1] + proto_deps += [dep.split(":")[0] + ":" + dep.split(":")[1] + "_only" for dep in deps if dep.find(":") != -1 and dep.find("com_google_googleapis") == -1] proto_deps += [dep for dep in deps if dep.find("com_google_googleapis") != -1] if well_known_protos: proto_deps += well_known_proto_libs() diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD index 6444425ad1b..555c46f74d2 100644 --- a/src/proto/grpc/channelz/BUILD +++ b/src/proto/grpc/channelz/BUILD @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("//bazel:grpc_build_system.bzl", "grpc_cc_grpc_library", "grpc_cc_proto_library", "grpc_internal_proto_library", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") licenses(["notice"]) @@ -21,27 +21,14 @@ grpc_package( visibility = "public", ) -grpc_internal_proto_library( +# TODO(roth): Migrate this to use separate +# grpc_internal_proto_library/grpc_cc_proto_library/grpc_cc_grpc_library +# rules when internal build system limitations are resolved. +grpc_proto_library( name = "channelz_proto", srcs = ["channelz.proto"], has_services = True, - deps = [ - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - ], -) - -grpc_cc_proto_library( - name = "channelz_cc_proto", - deps = ["channelz_proto"], -) - -grpc_cc_grpc_library( - name = "channelz_cc_grpc", - srcs = ["channelz_proto"], - deps = ["channelz_cc_proto"], + well_known_protos = True, ) filegroup( diff --git a/src/proto/grpc/reflection/v1/BUILD b/src/proto/grpc/reflection/v1/BUILD index e81453d7f72..7319477dfe9 100644 --- a/src/proto/grpc/reflection/v1/BUILD +++ b/src/proto/grpc/reflection/v1/BUILD @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("//bazel:grpc_build_system.bzl", "grpc_cc_grpc_library", "grpc_cc_proto_library", "grpc_internal_proto_library", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") licenses(["notice"]) @@ -21,21 +21,12 @@ grpc_package( visibility = "public", ) -grpc_internal_proto_library( +# TODO(roth): Migrate this to use separate +# grpc_internal_proto_library/grpc_cc_proto_library/grpc_cc_grpc_library +# rules when internal build system limitations are resolved. +grpc_proto_library( name = "reflection_proto", srcs = ["reflection.proto"], - has_services = True, -) - -grpc_cc_proto_library( - name = "reflection_cc_proto", - deps = ["reflection_proto"], -) - -grpc_cc_grpc_library( - name = "reflection_cc_grpc", - srcs = ["reflection_proto"], - deps = ["reflection_cc_proto"], ) filegroup( diff --git a/src/proto/grpc/reflection/v1alpha/BUILD b/src/proto/grpc/reflection/v1alpha/BUILD index 7059edc4f73..054b7f88058 100644 --- a/src/proto/grpc/reflection/v1alpha/BUILD +++ b/src/proto/grpc/reflection/v1alpha/BUILD @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("//bazel:grpc_build_system.bzl", "grpc_cc_grpc_library", "grpc_cc_proto_library", "grpc_internal_proto_library", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") licenses(["notice"]) @@ -21,21 +21,12 @@ grpc_package( visibility = "public", ) -grpc_internal_proto_library( +# TODO(roth): Migrate this to use separate +# grpc_internal_proto_library/grpc_cc_proto_library/grpc_cc_grpc_library +# rules when internal build system limitations are resolved. +grpc_proto_library( name = "reflection_proto", srcs = ["reflection.proto"], - has_services = True, -) - -grpc_cc_proto_library( - name = "reflection_cc_proto", - deps = ["reflection_proto"], -) - -grpc_cc_grpc_library( - name = "reflection_cc_grpc", - srcs = ["reflection_proto"], - deps = ["reflection_cc_proto"], ) filegroup( diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index d1cc7a59188..20871f9fea2 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -383,7 +383,7 @@ genrule( # generated by a separate proto_library rule, so we use an alias to make # things work. alias( - name = "_empty_proto_only", + name = "empty_proto_only", actual = "empty_proto", ) diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel index a477e82bc3b..49f9e8beec6 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel +++ b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel @@ -19,12 +19,12 @@ package(default_visibility = ["//visibility:public"]) py_proto_library( name = "channelz_py_pb2", imports = ["../../"], - deps = ["//src/proto/grpc/channelz:channelz_proto"], + deps = ["//src/proto/grpc/channelz:channelz_proto_only"], ) py_grpc_library( name = "channelz_py_pb2_grpc", - srcs = ["//src/proto/grpc/channelz:channelz_proto"], + srcs = ["//src/proto/grpc/channelz:channelz_proto_only"], strip_prefixes = ["src.python.grpcio_channelz."], deps = [":channelz_py_pb2"], ) diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel index 0e72b2876b0..9fc0b995064 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel @@ -19,12 +19,12 @@ package(default_visibility = ["//visibility:public"]) py_proto_library( name = "reflection_py_pb2", imports = ["../../"], - deps = ["//src/proto/grpc/reflection/v1alpha:reflection_proto"], + deps = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_only"], ) py_grpc_library( name = "reflection_py_pb2_grpc", - srcs = ["//src/proto/grpc/reflection/v1alpha:reflection_proto"], + srcs = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_only"], strip_prefixes = ["src.python.grpcio_reflection."], deps = ["reflection_py_pb2"], ) diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index ab57b6e4e26..9befbe614bb 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -342,7 +342,7 @@ grpc_cc_test( "//:grpc++", "//:grpcpp_channelz", "//src/core:slice", - "//src/proto/grpc/channelz:channelz_cc_grpc", + "//src/proto/grpc/channelz:channelz_proto", "//src/proto/grpc/testing:echo_cc_grpc", "//src/proto/grpc/testing:echo_messages_cc_proto", "//test/core/event_engine:event_engine_test_utils", diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index 6710240b4ed..a186aa0a6ff 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -49,7 +49,7 @@ grpc_cc_library( deps = [ "//:grpc++", "//:grpc++_config_proto", - "//src/proto/grpc/reflection/v1alpha:reflection_cc_grpc", + "//src/proto/grpc/reflection/v1alpha:reflection_proto", ], ) @@ -106,7 +106,7 @@ grpc_cc_library( ], deps = [ "//:grpc++", - "//src/proto/grpc/channelz:channelz_cc_proto", + "//src/proto/grpc/channelz:channelz_proto", ], ) @@ -150,7 +150,7 @@ grpc_cc_library( deps = [ ":grpc++_proto_reflection_desc_db", "//:grpc++", - "//src/proto/grpc/reflection/v1alpha:reflection_cc_grpc", + "//src/proto/grpc/reflection/v1alpha:reflection_proto", ], ) @@ -332,7 +332,7 @@ grpc_cc_binary( ":grpc_cli_libs", ":test_config", "//:grpc++", - "//src/proto/grpc/reflection/v1alpha:reflection_cc_grpc", + "//src/proto/grpc/reflection/v1alpha:reflection_proto", ], ) @@ -353,7 +353,7 @@ grpc_cc_binary( "//:gpr", "//:grpc++", "//:grpcpp_channelz", - "//src/proto/grpc/channelz:channelz_cc_grpc", + "//src/proto/grpc/channelz:channelz_proto", "//test/cpp/util:test_config", "//test/cpp/util:test_util", ], @@ -384,7 +384,7 @@ grpc_cc_test( "//:grpc", "//:grpc++", "//:grpcpp_channelz", - "//src/proto/grpc/channelz:channelz_cc_grpc", + "//src/proto/grpc/channelz:channelz_proto", "//src/proto/grpc/testing:test_cc_grpc", "//test/core/test_util:grpc_test_util", "//test/cpp/util:test_util",