From dc6f6e36fc6af0344c1525d489da41c2fd66106e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 8 Jul 2021 16:53:42 -0700 Subject: [PATCH] Update visibility tags (#26641) * Update visibility tags Add some tags to the bazel build that we can leverage internally to help control visibility in the Google build system. * review feedback --- BUILD | 26 ++++++++++++++++++++++++-- bazel/grpc_build_system.bzl | 27 ++++++++++++++++++++------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/BUILD b/BUILD index eca620f4649..cc625bf8ec0 100644 --- a/BUILD +++ b/BUILD @@ -299,6 +299,7 @@ grpc_cc_library( language = "c++", public_hdrs = GPR_PUBLIC_HDRS, standalone = True, + visibility = ["@grpc:public"], deps = [ "gpr_base", ], @@ -351,7 +352,6 @@ grpc_cc_library( }, standalone = True, visibility = [ - "@grpc:alt_grpc_legacy", "@grpc:public", ], deps = [ @@ -395,7 +395,6 @@ grpc_cc_library( }, standalone = True, visibility = [ - "@grpc:alt_grpc++_legacy", "@grpc:public", ], deps = [ @@ -475,6 +474,7 @@ grpc_cc_library( public_hdrs = [ "include/grpcpp/xds_server_builder.h", ], + visibility = ["@grpc:xds"], deps = [ "grpc++_internals", ], @@ -531,6 +531,7 @@ grpc_cc_library( ], language = "c++", standalone = True, + visibility = ["@grpc:tsi"], deps = [ "alts_upb", "alts_util", @@ -681,6 +682,7 @@ grpc_cc_library( ], language = "c++", public_hdrs = GPR_PUBLIC_HDRS, + visibility = ["@grpc:alt_gpr_base_legacy"], deps = [ "debug_location", "google_api_upb", @@ -709,6 +711,7 @@ grpc_cc_library( "include/grpc/impl/codegen/sync_posix.h", "include/grpc/impl/codegen/sync_windows.h", ], + visibility = ["@grpc:public"], ) grpc_cc_library( @@ -717,6 +720,7 @@ grpc_cc_library( hdrs = ["src/core/lib/debug/trace.h"], language = "c++", public_hdrs = GRPC_PUBLIC_HDRS, + visibility = ["@grpc:trace"], deps = [ "gpr", "grpc_codegen", @@ -738,12 +742,14 @@ grpc_cc_library( name = "debug_location", language = "c++", public_hdrs = ["src/core/lib/gprpp/debug_location.h"], + visibility = ["@grpc:debug_location"], ) grpc_cc_library( name = "orphanable", language = "c++", public_hdrs = ["src/core/lib/gprpp/orphanable.h"], + visibility = ["@grpc:client_channel"], deps = [ "debug_location", "gpr_base", @@ -784,6 +790,7 @@ grpc_cc_library( name = "ref_counted_ptr", language = "c++", public_hdrs = ["src/core/lib/gprpp/ref_counted_ptr.h"], + visibility = ["@grpc:ref_counted_ptr"], deps = [ "gpr_base", ], @@ -1128,6 +1135,7 @@ grpc_cc_library( ], language = "c++", public_hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS, + visibility = ["@grpc:alt_grpc_base_legacy"], deps = [ "dual_ref_counted", "gpr_base", @@ -1146,6 +1154,7 @@ grpc_cc_library( "src/core/lib/surface/lame_client.cc", ], language = "c++", + visibility = ["@grpc:alt_grpc_base_legacy"], deps = [ "atomic", "gpr_base", @@ -1261,6 +1270,7 @@ grpc_cc_library( "upb_lib", ], language = "c++", + visibility = ["@grpc:client_channel"], deps = [ "debug_location", "gpr_base", @@ -1429,6 +1439,7 @@ grpc_cc_library( "include/grpc/impl/codegen/status.h", "include/grpc/impl/codegen/slice.h", ], + visibility = ["@grpc:public"], deps = [ "gpr_codegen", ], @@ -2451,6 +2462,7 @@ grpc_cc_library( "absl/strings", ], language = "c++", + visibility = ["@grpc:grpclb"], deps = [ "gpr_base", "grpc_base_c", @@ -2613,6 +2625,7 @@ grpc_cc_library( "src/core/tsi/transport_security_interface.h", ], language = "c++", + visibility = ["@grpc:tsi_interface"], deps = [ "gpr", "grpc_trace", @@ -2657,6 +2670,7 @@ grpc_cc_library( "libcrypto", ], language = "c++", + visibility = ["@grpc:alts_frame_protector"], deps = [ "gpr_base", "grpc_base_c", @@ -2686,6 +2700,7 @@ grpc_cc_library( ], language = "c++", public_hdrs = GRPC_SECURE_PUBLIC_HDRS, + visibility = ["@grpc:tsi"], deps = [ "alts_upb", "gpr", @@ -2729,6 +2744,7 @@ grpc_cc_library( "upb_lib", ], language = "c++", + visibility = ["@grpc:tsi"], deps = [ "alts_frame_protector", "alts_util", @@ -2751,6 +2767,7 @@ grpc_cc_library( ], language = "c++", public_hdrs = GRPCXX_PUBLIC_HDRS, + visibility = ["@grpc:alt_grpc++_base_legacy"], deps = [ "gpr_base", "grpc", @@ -2875,6 +2892,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/sync_stream.h", "include/grpcpp/impl/codegen/time.h", ], + visibility = ["@grpc:public"], deps = [ "grpc++_internal_hdrs_only", "grpc_codegen", @@ -2904,6 +2922,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/proto_buffer_writer.h", "include/grpcpp/impl/codegen/proto_utils.h", ], + visibility = ["@grpc:public"], deps = [ "grpc++_codegen_base", "grpc++_config_proto", @@ -2920,6 +2939,7 @@ grpc_cc_library( "include/grpc++/impl/codegen/config_protobuf.h", "include/grpcpp/impl/codegen/config_protobuf.h", ], + visibility = ["@grpc:public"], ) grpc_cc_library( @@ -2936,6 +2956,7 @@ grpc_cc_library( "include/grpc++/ext/proto_server_reflection_plugin.h", "include/grpcpp/ext/proto_server_reflection_plugin.h", ], + visibility = ["@grpc:public"], deps = [ "grpc++", "//src/proto/grpc/reflection/v1alpha:reflection_proto", @@ -3031,6 +3052,7 @@ grpc_cc_library( "include/grpcpp/test/mock_stream.h", "include/grpcpp/test/server_context_test_spouse.h", ], + visibility = ["@grpc:grpc++_test"], deps = [ "gpr_base", "grpc++", diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index a94f7508a08..d54adf9b145 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -70,18 +70,31 @@ def _update_visibility(visibility): # Visibility rules prefixed with '@grpc_' are used to flag different visibility rule # classes upstream. + PUBLIC = ["//visibility:public"] + PRIVATE = ["//:__subpackages__"] VISIBILITY_TARGETS = { - "alt_grpc_legacy": [], - "alt_grpc++_legacy": [], - "endpoint_tests": [], - "grpc_opencensus_plugin": ["//visibility:public"], - "grpc_resolver_fake": [], - "public": ["//visibility:public"], + "alt_gpr_base_legacy": PRIVATE, + "alt_grpc++_base_legacy": PRIVATE, + "alt_grpc_base_legacy": PRIVATE, + "alts_frame_protector": PRIVATE, + "client_channel": PRIVATE, + "debug_location": PRIVATE, + "endpoint_tests": PRIVATE, + "grpclb": PRIVATE, + "grpc_opencensus_plugin": PUBLIC, + "grpc_resolver_fake": PRIVATE, + "grpc++_test": PRIVATE, + "public": PUBLIC, + "ref_counted_ptr": PRIVATE, + "trace": PRIVATE, + "tsi_interface": PRIVATE, + "tsi": PRIVATE, + "xds": PRIVATE, } final_visibility = [] for rule in visibility: if rule.startswith("@grpc:"): - for replacement in VISIBILITY_TARGETS[rule[6:]]: + for replacement in VISIBILITY_TARGETS[rule[len("@grpc:"):]]: final_visibility.append(replacement) else: final_visibility.append(rule)