From 5f31944b8942818aaf53571c76f5c6a9a9dafc72 Mon Sep 17 00:00:00 2001 From: Googler Date: Sat, 29 Apr 2017 03:34:50 +0200 Subject: Custom module map for j2objc_library PiperOrigin-RevId: 154606005 --- .../lib/rules/objc/IntermediateArtifacts.java | 35 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java') diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java index 337ee963c6..8de811fe03 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java @@ -23,6 +23,7 @@ import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.rules.cpp.CppCompileAction.DotdFile; import com.google.devtools.build.lib.rules.cpp.CppHelper; import com.google.devtools.build.lib.rules.cpp.CppModuleMap; +import com.google.devtools.build.lib.rules.cpp.CppModuleMap.UmbrellaHeaderStrategy; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.PathFragment; @@ -46,22 +47,38 @@ public final class IntermediateArtifacts { private final BuildConfiguration buildConfiguration; private final String archiveFileNameSuffix; private final String outputPrefix; + private final UmbrellaHeaderStrategy umbrellaHeaderStrategy; IntermediateArtifacts(RuleContext ruleContext, String archiveFileNameSuffix, String outputPrefix) { - this(ruleContext, archiveFileNameSuffix, outputPrefix, ruleContext.getConfiguration()); + this(ruleContext, archiveFileNameSuffix, outputPrefix, ruleContext.getConfiguration(), + UmbrellaHeaderStrategy.DO_NOT_GENERATE); } IntermediateArtifacts(RuleContext ruleContext, String archiveFileNameSuffix) { - this(ruleContext, archiveFileNameSuffix, "", ruleContext.getConfiguration()); + this(ruleContext, archiveFileNameSuffix, "", ruleContext.getConfiguration(), + UmbrellaHeaderStrategy.DO_NOT_GENERATE); } - + IntermediateArtifacts(RuleContext ruleContext, String archiveFileNameSuffix, - String outputPrefix, BuildConfiguration buildConfiguration) { + UmbrellaHeaderStrategy umbrellaHeaderStrategy) { + this(ruleContext, archiveFileNameSuffix, "", ruleContext.getConfiguration(), + umbrellaHeaderStrategy); + } + + IntermediateArtifacts(RuleContext ruleContext, String archiveFileNameSuffix, String outputPrefix, + BuildConfiguration buildConfiguration) { + this(ruleContext, archiveFileNameSuffix, outputPrefix, buildConfiguration, + UmbrellaHeaderStrategy.DO_NOT_GENERATE); + } + + IntermediateArtifacts(RuleContext ruleContext, String archiveFileNameSuffix, String outputPrefix, + BuildConfiguration buildConfiguration, UmbrellaHeaderStrategy umbrellaHeaderStrategy) { this.ruleContext = ruleContext; this.buildConfiguration = buildConfiguration; this.archiveFileNameSuffix = Preconditions.checkNotNull(archiveFileNameSuffix); this.outputPrefix = Preconditions.checkNotNull(outputPrefix); + this.umbrellaHeaderStrategy = umbrellaHeaderStrategy; } /** @@ -434,7 +451,15 @@ public final class IntermediateArtifacts { .replace(":", "_"); // To get Swift to pick up module maps, we need to name them "module.modulemap" and have their // parent directory in the module map search paths. - return new CppModuleMap(appendExtensionInGenfiles(".modulemaps/module.modulemap"), moduleName); + if (umbrellaHeaderStrategy == UmbrellaHeaderStrategy.GENERATE) { + return new CppModuleMap( + appendExtensionInGenfiles(".modulemaps/module.modulemap"), + appendExtensionInGenfiles(".modulemaps/umbrella.h"), + moduleName); + } else { + return new CppModuleMap( + appendExtensionInGenfiles(".modulemaps/module.modulemap"), moduleName); + } } /** -- cgit v1.2.3