Skip to content

Script for ensuring correct Envoy include paths#122

Merged
htuch merged 14 commits intoenvoyproxy:masterfrom
oschaaf:envoy-include-check
Aug 23, 2019
Merged

Script for ensuring correct Envoy include paths#122
htuch merged 14 commits intoenvoyproxy:masterfrom
oschaaf:envoy-include-check

Conversation

@oschaaf
Copy link
Copy Markdown
Member

@oschaaf oschaaf commented Aug 20, 2019

Let's see if the format check in CI flags the current state as a failure with this.

Signed-off-by: Otto van der Schaaf oschaaf@we-amp.com

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Aug 20, 2019

While the ci script seems to do what it is supposed to do in CI, referencing envoy includes via external/envoy/source/... unfortunately fails, which is sad. It seems that when we have @repo=envoy in a target, bazel won't set up these includes for Envoy

@oschaaf oschaaf mentioned this pull request Aug 20, 2019
4 tasks
@htuch
Copy link
Copy Markdown
Member

htuch commented Aug 21, 2019

@oschaaf how do the existing external/envoy references work?

Do we need to fork or do some surgery on envoy_cc_library to avoid this include path masking? It seems the external/<dep> path is common, see https://docs.bazel.build/versions/master/cpp-use-cases.html#adding-include-paths.

@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Aug 21, 2019

So envoy_cc_test_library is doing something different compared to envoy_cc_library when it comes to exporting includes, which allows #include external/envoy/... to work.
I think the following line in the definition of enovy_cc_library might be relevant:

include_prefix = envoy_include_prefix(native.package_name())

and then

def envoy_include_prefix(path):
    if path.startswith("source/") or path.startswith("include/"):
        return "/".join(path.split("/")[1:])
    return None

I propose adding a flag to envoy_cc_library that would allow us to opt-out of having it manipulate these prefixes for us. I think that is a simple change, and voids the need for a CI check in NH to enforce the right include paths. The downside is that nearly all #include paths in NH would have to be updated, but that is a mechanical change.

@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Aug 21, 2019

@oschaaf oschaaf requested a review from htuch August 21, 2019 22:37
@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Aug 21, 2019

After chatting, we have found a way forward with this with a different modification to envoy_cc_library [1]. The discussed approach, where we'll export foo_with_external_headers separately, will probably mean we will need this script to check for correct envoy includes, so requesting a review to start preparing this for merge.

[1]

def envoy_cc_library(
.... # we add a parallel native.cc_library
    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,

/assign htuch

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is exactly what we were after I reckon.

Comment thread tools/check_envoy_includes.py Outdated
from pathlib import Path

def get_inspection_targets_from_dir(dir):
result = []
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this match the style in https://github.com/envoyproxy/nighthawk/blob/master/test/integration/integration_test.py? Ideally same style, check/fix_format applies.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran it through fix fomat to resolve, ptal?

Comment thread tools/check_envoy_includes.py Outdated
Comment thread tools/check_envoy_includes.py Outdated
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Aug 22, 2019

For context, linking the PR to Envoy which would allows us to disambiguate the headers:
envoyproxy/envoy#8005

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Aug 22, 2019

Ready for another look
/assign htuch

If we're happy with the way this looks, I propose adding the actual include changes here to make the new CI format check happy?

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks. Just a few comments.
/wait

Comment thread source/client/service_impl.h
Comment thread source/common/utility.cc Outdated
Comment thread tools/check_envoy_includes.py Outdated
Comment thread tools/check_envoy_includes.py Outdated
- Has all include changes modulo platform specific ones that need to be
  treated separately [1]. It's worth noting that format check fails to flag
  these as it can't find these files either, and as such will refrain
  from flagging the include as an error.
- Includes header formatting changes in an attempt to address review
  feedback

[1] filesystem_impl.h & thread_impl.h

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Aug 22, 2019

Status:

  • Updated the Envoy dependency to the revision that has envoy_cc_library: add export of foo_with_external_headers envoy#8005
  • I had to include fixes to accommodate for changes in Envoy to this rather large change. Fortunately they are low-complexity
  • Include paths are disambiguated modulo filesystem_impl.h & thread_impl.h which play by different rules. Those will be taken on in a follow up.
  • Header ordering is reconfigured to minimize the diff yet take advantage of the new paths for more clarity.
  • CI is all green
  • Review comments addressed

/assign htuch
Ready for another pass!

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@htuch htuch merged commit 24a11ff into envoyproxy:master Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants