Skip to content

Commit a6ef0b3

Browse files
adrianimbodencopybara-github
authored andcommitted
add externalInclude information to compilation_context
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
1 parent 57d324d commit a6ef0b3

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationContext.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,17 @@ public Depset getStarlarkIncludeDirs() {
228228
.collect(ImmutableList.toImmutableList())));
229229
}
230230

231+
@Override
232+
public Depset getStarlarkExternalIncludeDirs() {
233+
return Depset.of(
234+
String.class,
235+
NestedSetBuilder.wrap(
236+
Order.STABLE_ORDER,
237+
getExternalIncludeDirs().stream()
238+
.map(PathFragment::getSafePathString)
239+
.collect(ImmutableList.toImmutableList())));
240+
}
241+
231242
@Override
232243
public Depset getStarlarkQuoteIncludeDirs() {
233244
return Depset.of(

‎src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcCompilationContextApi.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ public interface CcCompilationContextApi<FileT extends FileApi> extends Starlark
8484
structField = true)
8585
Depset getStarlarkIncludeDirs();
8686

87+
@StarlarkMethod(
88+
name = "external_includes",
89+
doc =
90+
"Returns the set of search paths (as strings) for external header files referenced by"
91+
+ " angle bracket. Usually passed with -isystem.",
92+
structField = true)
93+
Depset getStarlarkExternalIncludeDirs();
94+
8795
@StarlarkMethod(
8896
name = "quote_includes",
8997
doc =

0 commit comments

Comments
 (0)