Restrict module usage to C++ actions. Other actions don't support compiling
using C++ modules (yet) and thus we are paying some of the cost such as
building transitive modules and a taller critical path without reaping any
benefits.
@@ -320,9 +320,7 @@ public class CppCompileActionBuilder {
// finalizeCompileActionBuilder on this builder.
Preconditions.checkNotNull(shouldScanIncludes);
Preconditions.checkNotNull(featureConfiguration);
- boolean useHeaderModules =
- allowUsingHeaderModules
- && featureConfiguration.isEnabled(CppRuleClasses.USE_HEADER_MODULES);
+ boolean useHeaderModules = useHeaderModules();
if (featureConfiguration.actionIsConfigured(getActionName())) {
for (String executionRequirement :
@@ -473,7 +471,10 @@ public class CppCompileActionBuilder {
private boolean useHeaderModules() {
return allowUsingHeaderModules
- && featureConfiguration.isEnabled(CppRuleClasses.USE_HEADER_MODULES);
+ && featureConfiguration.isEnabled(CppRuleClasses.USE_HEADER_MODULES)
+ && (sourceFile.isFileType(CppFileTypes.CPP_SOURCE)
+ || sourceFile.isFileType(CppFileTypes.CPP_HEADER)
+ || sourceFile.isFileType(CppFileTypes.CPP_MODULE_MAP));
}
private boolean shouldPruneModules() {
