cc_proto_library: Honor --cc_proto_library_header_suffixes for WKPs
Closes #11121.
PiperOrigin-RevId: 315661721
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java
index 1291c2f..c98d9367 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java
@@ -177,7 +177,7 @@
// Compute and register files generated by this proto library.
Collection<Artifact> outputs = new ArrayList<>();
if (areSrcsBlacklisted()) {
- registerBlacklistedSrcs(protoInfo, compilationHelper);
+ registerBlacklistedSrcs(protoInfo, protoConfiguration, compilationHelper);
headerProvider = null;
} else if (!protoInfo.getDirectProtoSources().isEmpty()) {
Collection<Artifact> headers =
@@ -417,7 +417,8 @@
return result.build();
}
- private void registerBlacklistedSrcs(ProtoInfo protoInfo, CcCompilationHelper helper) {
+ private static void registerBlacklistedSrcs(
+ ProtoInfo protoInfo, ProtoConfiguration protoConfiguration, CcCompilationHelper helper) {
// Hack: This is a proto_library for descriptor.proto or similar.
//
// The headers of those libraries are precomputed . They are also explicitly part of normal
@@ -429,8 +430,9 @@
// proto library rules.
ImmutableList.Builder<PathFragment> headers = new ImmutableList.Builder<>();
for (Artifact source : protoInfo.getDirectProtoSources()) {
- headers.add(FileSystemUtils.replaceExtension(source.getRootRelativePath(), ".pb.h"));
- headers.add(FileSystemUtils.replaceExtension(source.getRootRelativePath(), ".proto.h"));
+ for (String suffix : protoConfiguration.ccProtoLibraryHeaderSuffixes()) {
+ headers.add(FileSystemUtils.replaceExtension(source.getRootRelativePath(), suffix));
+ }
}
// We add the header to the proto_library's module map as additional (textual) header for
// two reasons: