From 99a85e79a11cef98d0e08db21ab94833398381af Mon Sep 17 00:00:00 2001 From: hvd Date: Tue, 10 Aug 2021 08:05:03 -0700 Subject: [PATCH] Automated rollback of commit 92f7b58672baffe5a230f675d7197c2a10892284. *** Reason for rollback *** Breakage in blaze nightly *** Original change description *** Get rid of unused j2objc module map PiperOrigin-RevId: 389885762 --- .../lib/rules/objc/CompilationSupport.java | 41 +++++++++++++++++++ .../build/lib/rules/objc/J2ObjcLibrary.java | 18 +++++++- 2 files changed, 58 insertions(+), 1 deletion(-) 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 a82fe4488e7a5f..cc5e448c996342 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 @@ -1629,6 +1629,47 @@ private Optional getPchFile() { return Optional.fromNullable(pchHdr); } + /** + * Registers an action that will generate a clang module map for this target, using the hdrs + * attribute of this rule. + */ + public CompilationSupport registerGenerateModuleMapAction( + CompilationArtifacts compilationArtifacts) throws RuleErrorException, InterruptedException { + // TODO(bazel-team): Include textual headers in the module map when Xcode 6 support is + // dropped. + // TODO(b/32225593): Include private headers in the module map. + CcCompilationHelper ccCompilationHelper = + new CcCompilationHelper( + ruleContext, + ruleContext, + ruleContext.getLabel(), + CppHelper.getGrepIncludes(ruleContext), + cppSemantics, + getFeatureConfigurationForSwiftModuleMap( + ruleContext, toolchain, buildConfiguration, cppSemantics), + CcCompilationHelper.SourceCategory.CC_AND_OBJC, + toolchain, + toolchain.getFdoContext(), + buildConfiguration, + TargetUtils.getExecutionInfo( + ruleContext.getRule(), ruleContext.isAllowTagsPropagation()), + /* shouldProcessHeaders= */ false); + + ImmutableSortedSet publicHeaders = + Stream.concat( + attributes.hdrs().toList().stream(), + compilationArtifacts.getAdditionalHdrs().toList().stream()) + .collect(toImmutableSortedSet(naturalOrder())); + + CppModuleMap moduleMap = intermediateArtifacts.swiftModuleMap(); + + ccCompilationHelper.setCppModuleMap(moduleMap).addPublicHeaders(publicHeaders); + + ccCompilationHelper.compile(ruleContext); + + return this; + } + /** Registers an action to generate an extra clang module map. */ private CompilationSupport generateExtraModuleMap( CppModuleMap moduleMap, diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcLibrary.java index 0c3a230e436f55..af23d4a242c583 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcLibrary.java @@ -39,8 +39,11 @@ * linking into the final application bundle. See {@link J2ObjcLibraryBaseRule} for details. */ public class J2ObjcLibrary implements RuleConfiguredTargetFactory { + private final CppSemantics cppSemantics; - protected J2ObjcLibrary(CppSemantics cppSemantics) {} + protected J2ObjcLibrary(CppSemantics cppSemantics) { + this.cppSemantics = cppSemantics; + } public static final String NO_ENTRY_CLASS_ERROR_MSG = "Entry classes must be specified when flag --compilation_mode=opt is on in order to" @@ -59,6 +62,7 @@ private ObjcCommon common(RuleContext ruleContext) throws InterruptedException { .addDirectCcCompilationContexts( j2objcCcInfos.stream().map(J2ObjcCcInfo::getCcInfo).collect(toList())) .setIntermediateArtifacts(ObjcRuleClasses.intermediateArtifacts(ruleContext)) + .setHasModuleMap() .build(); } @@ -83,6 +87,18 @@ public ConfiguredTarget create(RuleContext ruleContext) J2ObjcMappingFileProvider.union( ruleContext.getPrerequisites("deps", J2ObjcMappingFileProvider.PROVIDER)); + CompilationArtifacts moduleMapCompilationArtifacts = + new CompilationArtifacts.Builder() + .setIntermediateArtifacts(ObjcRuleClasses.intermediateArtifacts(ruleContext)) + .build(); + + new CompilationSupport.Builder(ruleContext, cppSemantics) + .setIntermediateArtifacts(ObjcRuleClasses.intermediateArtifacts(ruleContext)) + .doNotUsePch() + .build() + .registerGenerateModuleMapAction(moduleMapCompilationArtifacts) + .validateAttributes(); + return new RuleConfiguredTargetBuilder(ruleContext) .setFilesToBuild(NestedSetBuilder.emptySet(STABLE_ORDER)) .add(RunfilesProvider.class, RunfilesProvider.EMPTY)