Skip to content

Commit

Permalink
Fewer external deps (envoyproxy#36187)
Browse files Browse the repository at this point in the history
Commit Message: Remove the native.bind entries for the following
libraries:

- libcircllhist
- uring
- ares
- xxhash
- sqlparser
- tclap
- fmtlib
- spdlog
- benchmark
- libsxg
- yaml_cpp
- event
- colm
- ragel
- zlib
- brotlienc
- brotlidec
- zstd
- msgpack
- opentelemetry_api
- dd_trace_cpp
- cpp2sky
- json
- http_parser
- hessian2_codec_object_codec_lib
- hessian2_codec_codec_impl
- su-exec
- googletest
- protoc
- opencensus_trace
- opencensus_trace_b3
- opencensus_trace_cloud_trace_context
- opencensus_trace_grpc_trace_bin
- opencensus_trace_trace_context
- opencensus_exporter_ocagent
- opencensus_exporter_stdout
- opencensus_exporter_stackdriver
- opencensus_exporter_zipkin
- quiche_common_platform
- quiche_http2_adapter
- quiche_http2_protocol
- quiche_http2_test_tools
- quiche_quic_platform
- quiche_quic_platform_base
- quiche_http2_hpack
- quiche_http2_hpack_decoder
- jwt_verify_lib
- simple_lru_cache_lib
- luajit
- tcmalloc
- tcmalloc_profile_marshaler
- tcmalloc_malloc_extension
- gperftools
- librdkafka

Update `external_deps` that used them to `deps` of their actual
locations.
Some examples:
- `zlib` → `//bazel/foreign_cc:zlib`
- `json` → `@com_github_nlohmann_json//:json`

The bindings that remain are either used by dependencies that need to be
updated or have uses in some envoy bazel rules that make removing them
trickier. These are the easy ones.


Risk Level: low
Testing: Building envoy and running integration test suites. Existing
tests pass.

---------

Signed-off-by: Alejandro R Sedeño <asedeno@google.com>
  • Loading branch information
asedeno committed Sep 19, 2024
1 parent fdfdad0 commit 8d74446
Show file tree
Hide file tree
Showing 122 changed files with 259 additions and 745 deletions.
4 changes: 2 additions & 2 deletions bazel/EXTERNAL_DEPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build process.
1. Define a new Bazel repository in [`bazel/repositories.bzl`](repositories.bzl),
in the `envoy_dependencies()` function.
2. Reference your new external dependency in some `envoy_cc_library` via the
`external_deps` attribute.
`deps` attribute.
3. `bazel test //test/...`

## External CMake (preferred)
Expand All @@ -28,7 +28,7 @@ This is the preferred style of adding dependencies that use CMake for their buil
2. Add an `envoy_cmake` rule to [`bazel/foreign_cc/BUILD`](foreign_cc/BUILD). This will reference
the source repository in step 1.
3. Reference your new external dependency in some `envoy_cc_library` via the name bound in step 1
`external_deps` attribute.
`deps` attribute.
4. `bazel test //test/...`

# Adding external dependencies to Envoy (Python)
Expand Down
4 changes: 2 additions & 2 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ def envoy_proto_descriptor(name, out, srcs = [], external_deps = []):
options.extend(["-I" + include_path for include_path in include_paths])
options.append("--descriptor_set_out=$@")

cmd = "$(location //external:protoc) " + " ".join(options + input_files)
cmd = "$(location @com_google_protobuf//:protoc) " + " ".join(options + input_files)
native.genrule(
name = name,
srcs = srcs,
outs = [out],
cmd = cmd,
tools = ["//external:protoc"],
tools = ["@com_google_protobuf//:protoc"],
)

# Dependencies on Google grpc should be wrapped with this function.
Expand Down
18 changes: 9 additions & 9 deletions bazel/envoy_internal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ def tcmalloc_external_dep(repository):
repository + "//bazel:disable_tcmalloc": None,
repository + "//bazel:disable_tcmalloc_on_linux_x86_64": None,
repository + "//bazel:disable_tcmalloc_on_linux_aarch64": None,
repository + "//bazel:debug_tcmalloc": envoy_external_dep_path("gperftools"),
repository + "//bazel:debug_tcmalloc_on_linux_x86_64": envoy_external_dep_path("gperftools"),
repository + "//bazel:debug_tcmalloc_on_linux_aarch64": envoy_external_dep_path("gperftools"),
repository + "//bazel:gperftools_tcmalloc": envoy_external_dep_path("gperftools"),
repository + "//bazel:gperftools_tcmalloc_on_linux_x86_64": envoy_external_dep_path("gperftools"),
repository + "//bazel:gperftools_tcmalloc_on_linux_aarch64": envoy_external_dep_path("gperftools"),
repository + "//bazel:linux_x86_64": envoy_external_dep_path("tcmalloc"),
repository + "//bazel:linux_aarch64": envoy_external_dep_path("tcmalloc"),
"//conditions:default": envoy_external_dep_path("gperftools"),
repository + "//bazel:debug_tcmalloc": repository + "//bazel/foreign_cc:gperftools",
repository + "//bazel:debug_tcmalloc_on_linux_x86_64": repository + "//bazel/foreign_cc:gperftools",
repository + "//bazel:debug_tcmalloc_on_linux_aarch64": repository + "//bazel/foreign_cc:gperftools",
repository + "//bazel:gperftools_tcmalloc": repository + "//bazel/foreign_cc:gperftools",
repository + "//bazel:gperftools_tcmalloc_on_linux_x86_64": repository + "//bazel/foreign_cc:gperftools",
repository + "//bazel:gperftools_tcmalloc_on_linux_aarch64": repository + "//bazel/foreign_cc:gperftools",
repository + "//bazel:linux_x86_64": "@com_github_google_tcmalloc//tcmalloc",
repository + "//bazel:linux_aarch64": "@com_github_google_tcmalloc//tcmalloc",
"//conditions:default": repository + "//bazel/foreign_cc:gperftools",
})

# Select the given values if default path normalization is on in the current build.
Expand Down
26 changes: 13 additions & 13 deletions bazel/envoy_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ def tcmalloc_external_deps(repository):
repository + "//bazel:disable_tcmalloc": [],
repository + "//bazel:disable_tcmalloc_on_linux_x86_64": [],
repository + "//bazel:disable_tcmalloc_on_linux_aarch64": [],
repository + "//bazel:debug_tcmalloc": [envoy_external_dep_path("gperftools")],
repository + "//bazel:debug_tcmalloc_on_linux_x86_64": [envoy_external_dep_path("gperftools")],
repository + "//bazel:debug_tcmalloc_on_linux_aarch64": [envoy_external_dep_path("gperftools")],
repository + "//bazel:gperftools_tcmalloc": [envoy_external_dep_path("gperftools")],
repository + "//bazel:gperftools_tcmalloc_on_linux_x86_64": [envoy_external_dep_path("gperftools")],
repository + "//bazel:gperftools_tcmalloc_on_linux_aarch64": [envoy_external_dep_path("gperftools")],
repository + "//bazel:debug_tcmalloc": [repository + "//bazel/foreign_cc:gperftools"],
repository + "//bazel:debug_tcmalloc_on_linux_x86_64": [repository + "//bazel/foreign_cc:gperftools"],
repository + "//bazel:debug_tcmalloc_on_linux_aarch64": [repository + "//bazel/foreign_cc:gperftools"],
repository + "//bazel:gperftools_tcmalloc": [repository + "//bazel/foreign_cc:gperftools"],
repository + "//bazel:gperftools_tcmalloc_on_linux_x86_64": [repository + "//bazel/foreign_cc:gperftools"],
repository + "//bazel:gperftools_tcmalloc_on_linux_aarch64": [repository + "//bazel/foreign_cc:gperftools"],
repository + "//bazel:linux_x86_64": [
envoy_external_dep_path("tcmalloc"),
envoy_external_dep_path("tcmalloc_profile_marshaler"),
envoy_external_dep_path("tcmalloc_malloc_extension"),
"@com_github_google_tcmalloc//tcmalloc",
"@com_github_google_tcmalloc//tcmalloc:profile_marshaler",
"@com_github_google_tcmalloc//tcmalloc:malloc_extension",
],
repository + "//bazel:linux_aarch64": [
envoy_external_dep_path("tcmalloc"),
envoy_external_dep_path("tcmalloc_profile_marshaler"),
envoy_external_dep_path("tcmalloc_malloc_extension"),
"@com_github_google_tcmalloc//tcmalloc",
"@com_github_google_tcmalloc//tcmalloc:profile_marshaler",
"@com_github_google_tcmalloc//tcmalloc:malloc_extension",
],
"//conditions:default": [envoy_external_dep_path("gperftools")],
"//conditions:default": [repository + "//bazel/foreign_cc:gperftools"],
})

# Envoy C++ library targets that need no transformations or additional dependencies before being
Expand Down
2 changes: 1 addition & 1 deletion bazel/envoy_pch.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def envoy_pch_library(
name,
includes,
deps,
external_deps,
visibility,
external_deps = [],
testonly = False,
repository = ""):
native.cc_library(
Expand Down
5 changes: 3 additions & 2 deletions bazel/envoy_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _envoy_cc_test_infrastructure_library(
extra_deps = []
pch_copts = []
if disable_pch:
extra_deps = [envoy_external_dep_path("googletest")]
extra_deps = ["@com_google_googletest//:gtest"]
else:
extra_deps = envoy_pch_deps(repository, "//test:test_pch")
pch_copts = envoy_pch_copts(repository, "//test:test_pch")
Expand Down Expand Up @@ -175,9 +175,10 @@ def envoy_cc_test(
linkopts = _envoy_test_linkopts() + linkopts,
linkstatic = envoy_linkstatic(),
malloc = tcmalloc_external_dep(repository),
deps = envoy_stdlib_deps() + deps + [envoy_external_dep_path(dep) for dep in external_deps + ["googletest"]] + [
deps = envoy_stdlib_deps() + deps + [envoy_external_dep_path(dep) for dep in external_deps] + [
repository + "//test:main",
repository + "//test/test_common:test_version_linkstamp",
"@com_google_googletest//:gtest",
] + envoy_pch_deps(repository, "//test:test_pch"),
# from https://github.com/google/googletest/blob/6e1970e2376c14bf658eb88f655a054030353f9f/googlemock/src/gmock.cc#L51
# 2 - by default, mocks act as StrictMocks.
Expand Down
19 changes: 0 additions & 19 deletions bazel/external/json.BUILD

This file was deleted.

20 changes: 6 additions & 14 deletions bazel/external/quiche.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2460,10 +2460,7 @@ envoy_quic_cc_library(
"quiche/quic/core/crypto/quic_compressed_certs_cache.h",
"quiche/quic/core/crypto/transport_parameters.h",
],
external_deps = [
"ssl",
"zlib",
],
external_deps = ["ssl"],
tags = [
"pg3",
],
Expand All @@ -2489,6 +2486,7 @@ envoy_quic_cc_library(
":quic_core_utils_lib",
":quic_core_versions_lib",
":quic_platform",
"@envoy//bazel/foreign_cc:zlib",
],
)

Expand All @@ -2502,9 +2500,6 @@ envoy_quic_cc_library(
"quiche/quic/core/crypto/quic_client_session_cache.h",
"quiche/quic/core/crypto/quic_crypto_client_config.h",
],
external_deps = [
"zlib",
],
tags = [
"pg3",
],
Expand All @@ -2513,6 +2508,7 @@ envoy_quic_cc_library(
":quic_core_crypto_client_proof_source_lib",
":quic_core_crypto_crypto_handshake_lib",
":quiche_common_platform_client_stats",
"@envoy//bazel/foreign_cc:zlib",
],
)

Expand All @@ -2524,10 +2520,7 @@ envoy_quic_cc_library(
hdrs = [
"quiche/quic/core/crypto/quic_crypto_server_config.h",
],
external_deps = [
"ssl",
"zlib",
],
external_deps = ["ssl"],
tags = [
"pg3",
],
Expand All @@ -2536,6 +2529,7 @@ envoy_quic_cc_library(
":quic_core_proto_crypto_server_config_proto_header",
":quic_core_server_id_lib",
":quic_server_crypto_tls_handshake_lib",
"@envoy//bazel/foreign_cc:zlib",
],
)

Expand Down Expand Up @@ -2658,9 +2652,7 @@ envoy_quic_cc_library(
name = "quic_core_crypto_proof_source_x509_lib",
srcs = ["quiche/quic/core/crypto/proof_source_x509.cc"],
hdrs = ["quiche/quic/core/crypto/proof_source_x509.h"],
external_deps = [
"ssl",
],
external_deps = ["ssl"],
deps = [
":quic_core_crypto_certificate_view_lib",
":quic_core_crypto_crypto_handshake_lib",
Expand Down
2 changes: 1 addition & 1 deletion bazel/foreign_cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ envoy_cmake(
deps = [
":ares",
":nghttp2",
":zlib",
"//external:ssl",
"//external:zlib",
],
)

Expand Down
4 changes: 2 additions & 2 deletions bazel/protobuf.patch
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ index e7555ee10..a93beb1c5 100644
diff --git a/src/google/protobuf/io/BUILD.bazel b/src/google/protobuf/io/BUILD.bazel
--- a/src/google/protobuf/io/BUILD.bazel
+++ b/src/google/protobuf/io/BUILD.bazel
@@ -138,7 +138,7 @@ cc_library(
@@ -138,6 +138,6 @@ cc_library(
"@com_google_absl//absl/log:absl_log",
] + select({
"//build_defs:config_msvc": [],
- "//conditions:default": ["@zlib"],
+ "//conditions:default": ["//external:zlib"],
+ "//conditions:default": ["@envoy//bazel/foreign_cc:zlib"],
}),
)

Expand Down
Loading

0 comments on commit 8d74446

Please sign in to comment.