From 52822e29c2d619841975aa504ed718d0504184ec Mon Sep 17 00:00:00 2001 From: "data-plane-api(CircleCI)" Date: Fri, 24 Aug 2018 20:42:26 +0000 Subject: [PATCH] proto: unify envoy_proto_library/api_proto_library. (#4233) In the latest iteration of https://github.com/envoyproxy/envoy/pull/4220, it was necessary to use PGV constraints on fuzzer inputs. To do this would require PGV generation in envoy_build_system.bzl. There is also quite a bit of mess in how we were doing envoy_proto_library() today. So, this PR allows us to throw away the custom envoy_proto_library() and benefit from leveraging a single source of Envoy proto build truth. Risk level: Low Testing: bazel test //test/... Signed-off-by: Harvey Tuch Mirrored from https://github.com/envoyproxy/envoy @ 28d5f4118d60f828b1453cd8ad25033f2c8e38ab --- bazel/api_build_system.bzl | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/bazel/api_build_system.bzl b/bazel/api_build_system.bzl index 497d82c5..af275ec5 100644 --- a/bazel/api_build_system.bzl +++ b/bazel/api_build_system.bzl @@ -88,7 +88,16 @@ def api_proto_library_internal(visibility = ["//visibility:private"], **kwargs): # gRPC stub generation. # TODO(htuch): Automatically generate go_proto_library and go_grpc_library # from api_proto_library. -def api_proto_library(name, visibility = ["//visibility:private"], srcs = [], deps = [], has_services = 0, require_py = 1): +def api_proto_library( + name, + visibility = ["//visibility:private"], + srcs = [], + deps = [], + external_proto_deps = [], + external_cc_proto_deps = [], + has_services = 0, + linkstatic = None, + require_py = 1): # This is now vestigial, since there are no direct consumers in # the data plane API. However, we want to maintain native proto_library support # in the proto graph to (1) support future C++ use of native rules with @@ -99,7 +108,7 @@ def api_proto_library(name, visibility = ["//visibility:private"], srcs = [], de native.proto_library( name = name, srcs = srcs, - deps = deps + [ + deps = deps + external_proto_deps + [ "@com_google_protobuf//:any_proto", "@com_google_protobuf//:descriptor_proto", "@com_google_protobuf//:duration_proto", @@ -107,7 +116,6 @@ def api_proto_library(name, visibility = ["//visibility:private"], srcs = [], de "@com_google_protobuf//:struct_proto", "@com_google_protobuf//:timestamp_proto", "@com_google_protobuf//:wrappers_proto", - "@googleapis//:api_httpbody_protos_proto", "@googleapis//:http_api_protos_proto", "@googleapis//:rpc_status_protos_lib", "@com_github_gogo_protobuf//:gogo_proto", @@ -123,8 +131,9 @@ def api_proto_library(name, visibility = ["//visibility:private"], srcs = [], de pgv_cc_proto_library( name = _Suffix(name, _CC_SUFFIX), srcs = srcs, + linkstatic = linkstatic, deps = [_LibrarySuffix(d, _CC_SUFFIX) for d in deps], - external_deps = [ + external_deps = external_cc_proto_deps + [ "@com_google_protobuf//:cc_wkt_protos", "@googleapis//:http_api_protos", "@googleapis//:rpc_status_protos", @@ -132,8 +141,19 @@ def api_proto_library(name, visibility = ["//visibility:private"], srcs = [], de ], visibility = ["//visibility:public"], ) + py_export_suffixes = [] if (require_py == 1): api_py_proto_library(name, srcs, deps, has_services) + py_export_suffixes = ["_py", "_py_genproto"] + + # Allow unlimited visibility for consumers + export_suffixes = ["", "_cc", "_cc_validate", "_cc_proto", "_cc_proto_genproto"] + py_export_suffixes + for s in export_suffixes: + native.alias( + name = name + "_export" + s, + actual = name + s, + visibility = ["//visibility:public"], + ) def api_cc_test(name, srcs, proto_deps): native.cc_test(