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 <htuch@google.com>

Mirrored from https://github.com/envoyproxy/envoy @ 28d5f4118d60f828b1453cd8ad25033f2c8e38ab
pull/620/head
data-plane-api(CircleCI) 6 years ago
parent 8e09edd8fe
commit 52822e29c2
  1. 28
      bazel/api_build_system.bzl

@ -88,7 +88,16 @@ def api_proto_library_internal(visibility = ["//visibility:private"], **kwargs):
# gRPC stub generation. # gRPC stub generation.
# TODO(htuch): Automatically generate go_proto_library and go_grpc_library # TODO(htuch): Automatically generate go_proto_library and go_grpc_library
# from api_proto_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 # This is now vestigial, since there are no direct consumers in
# the data plane API. However, we want to maintain native proto_library support # 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 # 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( native.proto_library(
name = name, name = name,
srcs = srcs, srcs = srcs,
deps = deps + [ deps = deps + external_proto_deps + [
"@com_google_protobuf//:any_proto", "@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto", "@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_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//:struct_proto",
"@com_google_protobuf//:timestamp_proto", "@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto", "@com_google_protobuf//:wrappers_proto",
"@googleapis//:api_httpbody_protos_proto",
"@googleapis//:http_api_protos_proto", "@googleapis//:http_api_protos_proto",
"@googleapis//:rpc_status_protos_lib", "@googleapis//:rpc_status_protos_lib",
"@com_github_gogo_protobuf//:gogo_proto", "@com_github_gogo_protobuf//:gogo_proto",
@ -123,8 +131,9 @@ def api_proto_library(name, visibility = ["//visibility:private"], srcs = [], de
pgv_cc_proto_library( pgv_cc_proto_library(
name = _Suffix(name, _CC_SUFFIX), name = _Suffix(name, _CC_SUFFIX),
srcs = srcs, srcs = srcs,
linkstatic = linkstatic,
deps = [_LibrarySuffix(d, _CC_SUFFIX) for d in deps], deps = [_LibrarySuffix(d, _CC_SUFFIX) for d in deps],
external_deps = [ external_deps = external_cc_proto_deps + [
"@com_google_protobuf//:cc_wkt_protos", "@com_google_protobuf//:cc_wkt_protos",
"@googleapis//:http_api_protos", "@googleapis//:http_api_protos",
"@googleapis//:rpc_status_protos", "@googleapis//:rpc_status_protos",
@ -132,8 +141,19 @@ def api_proto_library(name, visibility = ["//visibility:private"], srcs = [], de
], ],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
py_export_suffixes = []
if (require_py == 1): if (require_py == 1):
api_py_proto_library(name, srcs, deps, has_services) 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): def api_cc_test(name, srcs, proto_deps):
native.cc_test( native.cc_test(

Loading…
Cancel
Save