forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added include-path modification support to maistra-envoy repository (e…
…nvoyproxy#98) * Added include-path modification support to maistra-envoy repository * renamed modify-include-paths/ to patches/
- Loading branch information
Showing
2 changed files
with
254 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
From 90c6e192e9a0af4892374658f18b9b69feb3bf7e Mon Sep 17 00:00:00 2001 | ||
From: Dmitri Dolguikh <ddolguik@redhat.com> | ||
Date: Thu, 17 Jun 2021 12:09:05 -0700 | ||
Subject: [PATCH] build: modify include paths to be more bazel friendly | ||
|
||
--- | ||
bazel/envoy_build_system.bzl | 2 -- | ||
bazel/envoy_library.bzl | 17 ++++++----------- | ||
source/common/api/BUILD | 1 + | ||
source/common/common/BUILD | 6 ++++-- | ||
source/common/event/BUILD | 3 +++ | ||
source/common/filesystem/BUILD | 5 +++++ | ||
6 files changed, 19 insertions(+), 15 deletions(-) | ||
|
||
diff --git a/bazel/envoy_build_system.bzl b/bazel/envoy_build_system.bzl | ||
index e33386ed5b..79cb51ce69 100644 | ||
--- a/bazel/envoy_build_system.bzl | ||
+++ b/bazel/envoy_build_system.bzl | ||
@@ -10,7 +10,6 @@ load( | ||
_envoy_cc_library = "envoy_cc_library", | ||
_envoy_cc_posix_library = "envoy_cc_posix_library", | ||
_envoy_cc_win32_library = "envoy_cc_win32_library", | ||
- _envoy_include_prefix = "envoy_include_prefix", | ||
_envoy_proto_library = "envoy_proto_library", | ||
) | ||
load( | ||
@@ -204,7 +203,6 @@ envoy_cc_extension = _envoy_cc_extension | ||
envoy_cc_library = _envoy_cc_library | ||
envoy_cc_posix_library = _envoy_cc_posix_library | ||
envoy_cc_win32_library = _envoy_cc_win32_library | ||
-envoy_include_prefix = _envoy_include_prefix | ||
envoy_proto_library = _envoy_proto_library | ||
|
||
# Test wrappers (from envoy_test.bzl) | ||
diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl | ||
index ca64d5a09e..0b195d59c6 100644 | ||
--- a/bazel/envoy_library.bzl | ||
+++ b/bazel/envoy_library.bzl | ||
@@ -37,9 +37,10 @@ def tcmalloc_external_deps(repository): | ||
# passed to cc_library should be specified with this function. Note: this exists to ensure that | ||
# all envoy targets pass through an envoy-declared Starlark function where they can be modified | ||
# before being passed to a native bazel function. | ||
-def envoy_basic_cc_library(name, deps = [], external_deps = [], **kargs): | ||
+def envoy_basic_cc_library(name, deps = [], external_deps = [], include_prefix = None, **kargs): | ||
cc_library( | ||
name = name, | ||
+ include_prefix = include_prefix, | ||
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps], | ||
**kargs | ||
) | ||
@@ -123,6 +124,7 @@ def envoy_cc_library( | ||
tags = [], | ||
deps = [], | ||
strip_include_prefix = None, | ||
+ include_prefix = None, | ||
textual_hdrs = None, | ||
defines = []): | ||
if tcmalloc_dep: | ||
@@ -137,7 +139,7 @@ def envoy_cc_library( | ||
tags = tags, | ||
textual_hdrs = textual_hdrs, | ||
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps] + [ | ||
- repository + "//include/envoy/common:base_includes", | ||
+ repository + "//envoy/common:base_includes", | ||
repository + "//source/common/common:fmt_lib", | ||
envoy_external_dep_path("abseil_flat_hash_map"), | ||
envoy_external_dep_path("abseil_flat_hash_set"), | ||
@@ -145,10 +147,10 @@ def envoy_cc_library( | ||
envoy_external_dep_path("spdlog"), | ||
envoy_external_dep_path("fmtlib"), | ||
], | ||
- include_prefix = envoy_include_prefix(native.package_name()), | ||
alwayslink = 1, | ||
linkstatic = envoy_linkstatic(), | ||
strip_include_prefix = strip_include_prefix, | ||
+ include_prefix = include_prefix, | ||
defines = defines, | ||
) | ||
|
||
@@ -162,6 +164,7 @@ def envoy_cc_library( | ||
tags = ["nocompdb"] + tags, | ||
deps = [":" + name], | ||
strip_include_prefix = strip_include_prefix, | ||
+ include_prefix = include_prefix, | ||
) | ||
|
||
# Used to specify a library that only builds on POSIX | ||
@@ -194,14 +197,6 @@ def envoy_cc_win32_library(name, srcs = [], hdrs = [], **kargs): | ||
**kargs | ||
) | ||
|
||
-# Transform the package path (e.g. include/envoy/common) into a path for | ||
-# exporting the package headers at (e.g. envoy/common). Source files can then | ||
-# include using this path scheme (e.g. #include "envoy/common/time.h"). | ||
-def envoy_include_prefix(path): | ||
- if path.startswith("source/") or path.startswith("include/"): | ||
- return "/".join(path.split("/")[1:]) | ||
- return None | ||
- | ||
# Envoy proto targets should be specified with this function. | ||
def envoy_proto_library(name, external_deps = [], **kwargs): | ||
api_cc_py_proto_library( | ||
diff --git a/source/common/api/BUILD b/source/common/api/BUILD | ||
index 7e7264f8f0..36d8b63a23 100644 | ||
--- a/source/common/api/BUILD | ||
+++ b/source/common/api/BUILD | ||
@@ -39,6 +39,7 @@ envoy_cc_library( | ||
"//bazel:windows_x86_64": ["win32/os_sys_calls_impl.h"], | ||
"//conditions:default": ["posix/os_sys_calls_impl.h"], | ||
}) + envoy_select_hot_restart(["posix/os_sys_calls_impl_hot_restart.h"]), | ||
+ include_prefix = "source/common/api", | ||
strip_include_prefix = select({ | ||
"//bazel:windows_x86_64": "win32", | ||
"//conditions:default": "posix", | ||
diff --git a/source/common/common/BUILD b/source/common/common/BUILD | ||
index bf7701a21f..03b6fe1df0 100644 | ||
--- a/source/common/common/BUILD | ||
+++ b/source/common/common/BUILD | ||
@@ -5,7 +5,6 @@ load( | ||
"envoy_cc_platform_dep", | ||
"envoy_cc_posix_library", | ||
"envoy_cc_win32_library", | ||
- "envoy_include_prefix", | ||
"envoy_package", | ||
) | ||
|
||
@@ -98,7 +97,6 @@ envoy_basic_cc_library( | ||
"abseil_strings", | ||
"fmtlib", | ||
], | ||
- include_prefix = envoy_include_prefix(package_name()), | ||
deps = ["//include/envoy/common:base_includes"], | ||
) | ||
|
||
@@ -171,6 +169,7 @@ envoy_cc_library( | ||
envoy_cc_library( | ||
name = "logger_impl_lib_standard", | ||
hdrs = ["standard/logger_impl.h"], | ||
+ include_prefix = "source/common/common", | ||
strip_include_prefix = "standard", | ||
deps = [":base_logger_lib"], | ||
) | ||
@@ -185,6 +184,7 @@ envoy_cc_library( | ||
"//bazel:android_logger": ["android/logger_impl.h"], | ||
"//conditions:default": [], | ||
}), | ||
+ include_prefix = "source/common/common", | ||
strip_include_prefix = "android", | ||
deps = [":base_logger_lib"], | ||
) | ||
@@ -328,6 +328,7 @@ envoy_cc_posix_library( | ||
name = "thread_impl_lib", | ||
srcs = ["posix/thread_impl.cc"], | ||
hdrs = ["posix/thread_impl.h"], | ||
+ include_prefix = "source/common/common", | ||
strip_include_prefix = "posix", | ||
deps = [ | ||
":assert_lib", | ||
@@ -339,6 +340,7 @@ envoy_cc_win32_library( | ||
name = "thread_impl_lib", | ||
srcs = ["win32/thread_impl.cc"], | ||
hdrs = ["win32/thread_impl.h"], | ||
+ include_prefix = "source/common/common", | ||
strip_include_prefix = "win32", | ||
deps = [ | ||
":assert_lib", | ||
diff --git a/source/common/event/BUILD b/source/common/event/BUILD | ||
index c14a6ee08e..bcc3698b5f 100644 | ||
--- a/source/common/event/BUILD | ||
+++ b/source/common/event/BUILD | ||
@@ -25,6 +25,7 @@ envoy_cc_library( | ||
"posix/signal_impl.h", | ||
], | ||
}), | ||
+ include_prefix = "source/common/event", | ||
strip_include_prefix = select({ | ||
"//bazel:windows_x86_64": "win32", | ||
"//conditions:default": "posix", | ||
@@ -60,6 +61,7 @@ envoy_cc_posix_library( | ||
name = "signal_impl_lib", | ||
srcs = ["posix/signal_impl.cc"], | ||
hdrs = ["posix/signal_impl.h"], | ||
+ include_prefix = "source/common/event", | ||
strip_include_prefix = "posix", | ||
deps = [ | ||
":dispatcher_includes", | ||
@@ -72,6 +74,7 @@ envoy_cc_win32_library( | ||
name = "signal_impl_lib", | ||
srcs = ["win32/signal_impl.cc"], | ||
hdrs = ["win32/signal_impl.h"], | ||
+ include_prefix = "source/common/event", | ||
strip_include_prefix = "win32", | ||
deps = [ | ||
":dispatcher_includes", | ||
diff --git a/source/common/filesystem/BUILD b/source/common/filesystem/BUILD | ||
index afcf463ef0..c8b7b0d680 100644 | ||
--- a/source/common/filesystem/BUILD | ||
+++ b/source/common/filesystem/BUILD | ||
@@ -21,6 +21,7 @@ envoy_cc_win32_library( | ||
name = "directory_iterator_impl_lib", | ||
srcs = ["win32/directory_iterator_impl.cc"], | ||
hdrs = ["win32/directory_iterator_impl.h"], | ||
+ include_prefix = "source/common/filesystem", | ||
strip_include_prefix = "win32", | ||
deps = [ | ||
"//include/envoy/filesystem:filesystem_interface", | ||
@@ -31,6 +32,7 @@ envoy_cc_posix_library( | ||
name = "directory_iterator_impl_lib", | ||
srcs = ["posix/directory_iterator_impl.cc"], | ||
hdrs = ["posix/directory_iterator_impl.h"], | ||
+ include_prefix = "source/common/filesystem", | ||
strip_include_prefix = "posix", | ||
deps = [ | ||
"//include/envoy/filesystem:filesystem_interface", | ||
@@ -48,6 +50,7 @@ envoy_cc_posix_library( | ||
name = "filesystem_impl_lib", | ||
srcs = ["posix/filesystem_impl.cc"], | ||
hdrs = ["posix/filesystem_impl.h"], | ||
+ include_prefix = "source/common/filesystem", | ||
strip_include_prefix = "posix", | ||
deps = [ | ||
":file_shared_lib", | ||
@@ -58,6 +61,7 @@ envoy_cc_win32_library( | ||
name = "filesystem_impl_lib", | ||
srcs = ["win32/filesystem_impl.cc"], | ||
hdrs = ["win32/filesystem_impl.h"], | ||
+ include_prefix = "source/common/filesystem", | ||
strip_include_prefix = "win32", | ||
deps = [ | ||
":file_shared_lib", | ||
@@ -102,6 +106,7 @@ envoy_cc_library( | ||
external_deps = [ | ||
"event", | ||
], | ||
+ include_prefix = "source/common/filesystem", | ||
strip_include_prefix = select({ | ||
"//bazel:apple": "kqueue", | ||
"//bazel:windows_x86_64": "win32", | ||
-- | ||
2.29.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -o pipefail | ||
set -xi | ||
|
||
rm -rf envoy | ||
mv include/envoy ./ | ||
find ./envoy ./test ./source ./tools -name BUILD -print0 | xargs -0 sed -i 's/"\/\/include\//"\/\//g' | ||
find ./source -name BUILD -print0 | xargs -0 sed -i 's/"@envoy\/\/include\//"@envoy\/\//g' | ||
for dir in common docs exe extensions server; do | ||
find ./envoy ./source ./test ./tools \( -name \*.h -o -name \*.cc -o -name \*.j2 \) -print0 | xargs -0 sed -i "/Common.pb.h/!s/#include \"$dir\//#include \"source\/$dir\//g" | ||
done |