diff options
Diffstat (limited to 'src/main/java/com/google/devtools')
5 files changed, 35 insertions, 22 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java index e6972100c4..355d01b00b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java @@ -1303,7 +1303,7 @@ public final class CcLibraryHelper { semantics.setupCompilationContext(ruleContext, contextBuilder); return contextBuilder.build(); } - + private CppModuleMapAction createModuleMapAction( CppModuleMap moduleMap, PublicHeaders publicHeaders, @@ -1315,7 +1315,9 @@ public final class CcLibraryHelper { featureConfiguration.isEnabled(CppRuleClasses.EXCLUDE_PRIVATE_HEADERS_IN_MODULE_MAPS) ? ImmutableList.<Artifact>of() : privateHeaders, - publicHeaders.getModuleMapHeaders(), + featureConfiguration.isEnabled(CppRuleClasses.ONLY_DOTH_HEADERS_IN_MODULE_MAPS) + ? Iterables.filter(publicHeaders.getModuleMapHeaders(), CppFileTypes.MODULE_MAP_HEADER) + : publicHeaders.getModuleMapHeaders(), dependentModuleMaps, additionalExportedHeaders, compiledModule, diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java index a20ed3d09a..2ad342dd67 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java @@ -13,7 +13,9 @@ // limitations under the License. package com.google.devtools.build.lib.rules.cpp; +import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.util.FileTypeSet; import java.util.List; @@ -162,6 +164,25 @@ public final class CppFileTypes { public static final FileType CLIF_INPUT_PROTO = FileType.of(".ipb"); public static final FileType CLIF_OUTPUT_PROTO = FileType.of(".opb"); + /** Predicate that matches all artifacts that can be used in an objc Clang module map. */ + public static final Predicate<Artifact> MODULE_MAP_HEADER = + new Predicate<Artifact>() { + @Override + public boolean apply(Artifact artifact) { + if (artifact.isTreeArtifact()) { + // Tree artifact is basically a directory, which does not have any information about + // the contained files and their extensions. Here we assume the passed in tree artifact + // contains proper header files with .h extension. + return true; + } else { + // The current clang (clang-600.0.57) on Darwin doesn't support 'textual', so we can't + // have '.inc' files in the module map (since they're implictly textual). + // TODO(bazel-team): Use HEADERS file type once clang-700 is the base clang we support. + return artifact.getFilename().endsWith(".h"); + } + } + }; + public static final boolean mustProduceDotdFile(String source) { return !ASSEMBLER.matches(source) && !PIC_ASSEMBLER.matches(source) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java index 110908c057..024f26dc3f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java @@ -228,6 +228,13 @@ public class CppRuleClasses { public static final String GENERATE_SUBMODULES = "generate_submodules"; /** + * A string constant for the only_doth_headers_in_module_maps. + * + * <p>This feature filters any headers without a ".h" suffix from generated module maps. + */ + public static final String ONLY_DOTH_HEADERS_IN_MODULE_MAPS = "only_doth_headers_in_module_maps"; + + /** * A string constant for the no_legacy_features feature. * * <p>If this feature is enabled, Bazel will not extend the crosstool configuration with the diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java index a47526d4db..cbe8ce3b1d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java @@ -65,6 +65,7 @@ import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.rules.apple.AppleToolchain; import com.google.devtools.build.lib.rules.apple.Platform; import com.google.devtools.build.lib.rules.apple.Platform.PlatformType; +import com.google.devtools.build.lib.rules.cpp.CppFileTypes; import com.google.devtools.build.lib.rules.cpp.CppModuleMap; import com.google.devtools.build.lib.rules.cpp.CppModuleMapAction; import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; @@ -177,25 +178,6 @@ public abstract class CompilationSupport { } }; - /** Predicate that matches all artifacts that can be used in a Clang module map. */ - private static final Predicate<Artifact> MODULE_MAP_HEADER = - new Predicate<Artifact>() { - @Override - public boolean apply(Artifact artifact) { - if (artifact.isTreeArtifact()) { - // Tree artifact is basically a directory, which does not have any information about - // the contained files and their extensions. Here we assume the passed in tree artifact - // contains proper header files with .h extension. - return true; - } else { - // The current clang (clang-600.0.57) on Darwin doesn't support 'textual', so we can't - // have '.inc' files in the module map (since they're implictly textual). - // TODO(bazel-team): Use HEADERS file type once clang-700 is the base clang we support. - return artifact.getFilename().endsWith(".h"); - } - } - }; - /** * Defines a library that contains the transitive closure of dependencies. */ @@ -978,7 +960,7 @@ public abstract class CompilationSupport { */ public CompilationSupport registerGenerateModuleMapAction( CppModuleMap moduleMap, Iterable<Artifact> publicHeaders) { - publicHeaders = Iterables.filter(publicHeaders, MODULE_MAP_HEADER); + publicHeaders = Iterables.filter(publicHeaders, CppFileTypes.MODULE_MAP_HEADER); ruleContext.registerAction( new CppModuleMapAction( ruleContext.getActionOwner(), diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java index 60b1155d55..d93a499d2f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java @@ -310,6 +310,7 @@ public class CrosstoolCompilationSupport extends CompilationSupport { .add(CppRuleClasses.MODULE_MAPS) .add(CppRuleClasses.COMPILE_ALL_MODULES) .add(CppRuleClasses.EXCLUDE_PRIVATE_HEADERS_IN_MODULE_MAPS) + .add(CppRuleClasses.ONLY_DOTH_HEADERS_IN_MODULE_MAPS) .add(CppRuleClasses.COMPILE_ACTION_FLAGS_IN_FLAG_SET) .add(CppRuleClasses.DEPENDENCY_FILE) .add(CppRuleClasses.INCLUDE_PATHS); |