From 4abf358733749d45352e4fda3a611152d8cfaffb Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Wed, 21 Aug 2019 17:01:46 +0200 Subject: [PATCH 1/6] Flag for specifying handled include prefixes Signed-off-by: Otto van der Schaaf --- bazel/envoy_library.bzl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index b0f54ea64eb4..e9e21a6e9664 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -6,7 +6,6 @@ load( "envoy_external_dep_path", "envoy_linkstatic", ) -load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library") load("@envoy_api//bazel:api_build_system.bzl", "api_proto_library") # As above, but wrapped in list form for adding to dep lists. This smell seems needed as @@ -39,6 +38,7 @@ def envoy_cc_library( tags = [], deps = [], strip_include_prefix = None, + handle_include_prefixes = ["source/", "include/"], textual_hdrs = None): if tcmalloc_dep: deps += _tcmalloc_external_deps(repository) @@ -60,7 +60,7 @@ def envoy_cc_library( envoy_external_dep_path("spdlog"), envoy_external_dep_path("fmtlib"), ], - include_prefix = envoy_include_prefix(native.package_name()), + include_prefix = envoy_include_prefix(native.package_name(), handle_include_prefixes), alwayslink = 1, linkstatic = envoy_linkstatic(), linkstamp = select({ @@ -103,9 +103,10 @@ def envoy_cc_win32_library(name, srcs = [], hdrs = [], **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:]) +def envoy_include_prefix(path, handled_prefixes = ["source/", "include/"]): + for prefix in handled_prefixes: + if path.startswith(prefix): + return "/".join(path.split("/")[1:]) return None # Envoy proto targets should be specified with this function. From 16c5ea70b68cd2d7200f9ba2ce52718b43cf983a Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Thu, 22 Aug 2019 00:14:56 +0200 Subject: [PATCH 2/6] Add export of foo_with_external_headers Signed-off-by: Otto van der Schaaf --- bazel/envoy_library.bzl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index b0f54ea64eb4..9c3f0616f555 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -69,6 +69,14 @@ def envoy_cc_library( }), strip_include_prefix = strip_include_prefix, ) + native.cc_library( + name = name + "_with_external_headers", + hdrs = hdrs, + copts = envoy_copts(repository) + copts, + visibility = visibility, + deps = [":" + name], + strip_include_prefix = strip_include_prefix, + ) # Used to specify a library that only builds on POSIX def envoy_cc_posix_library(name, srcs = [], hdrs = [], **kargs): From a3d97f83728a497e7add422a7e56dbb753f33dd5 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Thu, 22 Aug 2019 14:55:06 +0200 Subject: [PATCH 3/6] Add comment Signed-off-by: Otto van der Schaaf --- bazel/envoy_library.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index 6d7648cadef9..bffe63b15af9 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -69,6 +69,8 @@ def envoy_cc_library( }), strip_include_prefix = strip_include_prefix, ) + # Intended for usage by external consumers. This allows them to disambiguate + # include paths via `external/envoy...` native.cc_library( name = name + "_with_external_headers", hdrs = hdrs, From 97fdd52947704c2944b0cf376f7e27028b131200 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Thu, 22 Aug 2019 15:02:25 +0200 Subject: [PATCH 4/6] Undo accidental change Signed-off-by: Otto van der Schaaf --- bazel/envoy_library.bzl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index bffe63b15af9..811189d0afb1 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -6,6 +6,7 @@ load( "envoy_external_dep_path", "envoy_linkstatic", ) +load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library") load("@envoy_api//bazel:api_build_system.bzl", "api_proto_library") # As above, but wrapped in list form for adding to dep lists. This smell seems needed as @@ -38,7 +39,6 @@ def envoy_cc_library( tags = [], deps = [], strip_include_prefix = None, - handle_include_prefixes = ["source/", "include/"], textual_hdrs = None): if tcmalloc_dep: deps += _tcmalloc_external_deps(repository) @@ -60,7 +60,7 @@ def envoy_cc_library( envoy_external_dep_path("spdlog"), envoy_external_dep_path("fmtlib"), ], - include_prefix = envoy_include_prefix(native.package_name(), handle_include_prefixes), + include_prefix = envoy_include_prefix(native.package_name()), alwayslink = 1, linkstatic = envoy_linkstatic(), linkstamp = select({ @@ -113,10 +113,9 @@ def envoy_cc_win32_library(name, srcs = [], hdrs = [], **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, handled_prefixes = ["source/", "include/"]): - for prefix in handled_prefixes: - if path.startswith(prefix): - return "/".join(path.split("/")[1:]) +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. @@ -135,4 +134,4 @@ def envoy_proto_library(name, external_deps = [], **kwargs): linkstatic = 1, visibility = ["//visibility:public"], **kwargs - ) + ) \ No newline at end of file From e92ae7afbeadc97d0361b01ef4375f63588702d3 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Thu, 22 Aug 2019 15:03:24 +0200 Subject: [PATCH 5/6] Add back whitespace add EOF Signed-off-by: Otto van der Schaaf --- bazel/envoy_library.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index 811189d0afb1..66b874541a63 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -134,4 +134,4 @@ def envoy_proto_library(name, external_deps = [], **kwargs): linkstatic = 1, visibility = ["//visibility:public"], **kwargs - ) \ No newline at end of file + ) From 0190f713d412553e725a203ddb07dc27edf160ce Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Thu, 22 Aug 2019 15:09:44 +0200 Subject: [PATCH 6/6] Fix format Signed-off-by: Otto van der Schaaf --- bazel/envoy_library.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index 66b874541a63..352dbfa5efd4 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -69,6 +69,7 @@ def envoy_cc_library( }), strip_include_prefix = strip_include_prefix, ) + # Intended for usage by external consumers. This allows them to disambiguate # include paths via `external/envoy...` native.cc_library(