Skip to content

Commit

Permalink
Automated rollback of commit 92f7b58.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Breakage in blaze nightly

*** Original change description ***

Get rid of unused j2objc module map

PiperOrigin-RevId: 389885762
  • Loading branch information
hvadehra authored and copybara-github committed Aug 10, 2021
1 parent f1531dc commit 99a85e7
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,47 @@ private Optional<Artifact> 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<Artifact> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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();
}

Expand All @@ -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.<Artifact>emptySet(STABLE_ORDER))
.add(RunfilesProvider.class, RunfilesProvider.EMPTY)
Expand Down

0 comments on commit 99a85e7

Please sign in to comment.