Skip to content

Commit

Permalink
add externalInclude information to compilation_context
Browse files Browse the repository at this point in the history
Hi bazel team

I use an aspect to run clangtidy on the codebase. It is based on https://github.com/erenon/bazel_clang_tidy.

To check my codebase with `-Werror`, I use the "new" feature `external_include_path` requested by #12009, introduced by commit 08936ae.

Now my clangtidy rules did not work anymore of course. As you can see in https://github.com/erenon/bazel_clang_tidy/blob/master/clang_tidy/clang_tidy.bzl, all the different include paths are being passed to the clang-tidy executable. I now also needed to pass the new external_includes to `clang-tidy`.

This PR adds `external_includes` to the `compilation_context` object. I looked at the style of the other `includes` and hope it is in line with your expectations.

Closes #18094.

PiperOrigin-RevId: 548070112
Change-Id: I212420d2f888c3af088c4afbf8202c848d19722e
  • Loading branch information
adrianimboden authored and Copybara-Service committed Jul 14, 2023
1 parent 57d324d commit a6ef0b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Expand Up @@ -228,6 +228,17 @@ public Depset getStarlarkIncludeDirs() {
.collect(ImmutableList.toImmutableList())));
}

@Override
public Depset getStarlarkExternalIncludeDirs() {
return Depset.of(
String.class,
NestedSetBuilder.wrap(
Order.STABLE_ORDER,
getExternalIncludeDirs().stream()
.map(PathFragment::getSafePathString)
.collect(ImmutableList.toImmutableList())));
}

@Override
public Depset getStarlarkQuoteIncludeDirs() {
return Depset.of(
Expand Down
Expand Up @@ -84,6 +84,14 @@ public interface CcCompilationContextApi<FileT extends FileApi> extends Starlark
structField = true)
Depset getStarlarkIncludeDirs();

@StarlarkMethod(
name = "external_includes",
doc =
"Returns the set of search paths (as strings) for external header files referenced by"
+ " angle bracket. Usually passed with -isystem.",
structField = true)
Depset getStarlarkExternalIncludeDirs();

@StarlarkMethod(
name = "quote_includes",
doc =
Expand Down

0 comments on commit a6ef0b3

Please sign in to comment.