Skip to content

Commit

Permalink
Tie platform inference in linkMultiArchBinary to the presence of the …
Browse files Browse the repository at this point in the history
…shouldLipo argument. Allows for use of other transitions besides apple_common.multi_arch_split with apple_common,link_multi_arch_binary and should_lipo = False.

RELNOTES: None.
PiperOrigin-RevId: 372148110
  • Loading branch information
Googler authored and copybara-github committed May 5, 2021
1 parent 8139503 commit 1a7b977
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,19 @@ public static AppleBinaryOutput linkMultiArchBinary(
boolean isStampingEnabled,
boolean shouldLipo)
throws InterruptedException, RuleErrorException, ActionConflictException {
MultiArchSplitTransitionProvider.validateMinimumOs(ruleContext);
PlatformType platformType = MultiArchSplitTransitionProvider.getPlatformType(ruleContext);
ApplePlatform platform = null;

AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
if (shouldLipo) {
MultiArchSplitTransitionProvider.validateMinimumOs(ruleContext);
PlatformType platformType = MultiArchSplitTransitionProvider.getPlatformType(ruleContext);

ApplePlatform platform = null;
try {
platform = appleConfiguration.getMultiArchPlatform(platformType);
} catch (IllegalArgumentException e) {
ruleContext.throwWithRuleError(e);
AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);

try {
platform = appleConfiguration.getMultiArchPlatform(platformType);
} catch (IllegalArgumentException e) {
ruleContext.throwWithRuleError(e);
}
}
ImmutableListMultimap<String, TransitiveInfoCollection> cpuToDepsCollectionMap =
MultiArchBinarySupport.transformMap(ruleContext.getPrerequisitesByConfiguration("deps"));
Expand Down Expand Up @@ -220,8 +223,7 @@ public static AppleBinaryOutput linkMultiArchBinary(
allLinkInputs,
isStampingEnabled,
cpuToDepsCollectionMap,
outputGroupCollector,
platform);
outputGroupCollector);

if (shouldLipo) {
NestedSetBuilder<Artifact> binariesToLipo = NestedSetBuilder.stableOrder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ public MultiArchBinarySupport(RuleContext ruleContext, CppSemantics cppSemantics
* collections which are propagated from the dependencies of that configuration
* @param outputMapCollector a map to which output groups created by compile action generation are
* added
* @param platform the current configuration from {@link
* AppleConfiguration#getMultiArchPlatform(PlatformType)}
* @return a map containing all single-architecture binaries that are linked from this call
* @throws RuleErrorException if there are attribute errors in the current rule context
*/
Expand All @@ -139,8 +137,7 @@ public ImmutableMap<String, Artifact> registerActions(
Iterable<Artifact> extraLinkInputs,
boolean isStampingEnabled,
ListMultimap<String, TransitiveInfoCollection> cpuToDepsCollectionMap,
Map<String, NestedSet<Artifact>> outputMapCollector,
ApplePlatform platform)
Map<String, NestedSet<Artifact>> outputMapCollector)
throws RuleErrorException, InterruptedException {

ImmutableMap.Builder<String, Artifact> platformToBinariesMap = ImmutableMap.builder();
Expand All @@ -163,8 +160,11 @@ public ImmutableMap<String, Artifact> registerActions(
.map(CcInfo::getCcLinkingContext)
.collect(toImmutableList());

// TODO(b/177442911): Use the target platform from platform info coming from split
// transition outputs instead of inferring this based on the target CPU.
ApplePlatform cpuPlatform = ApplePlatform.forTargetCpu(configCpu);
platformToBinariesMap.put(
platform.cpuStringWithTargetEnvironmentForTargetCpu(configCpu),
cpuPlatform.cpuStringWithTargetEnvironmentForTargetCpu(configCpu),
intermediateArtifacts.strippedSingleArchitectureBinary());

ObjcProvider objcProvider = dependencySpecificConfiguration.objcLinkProvider();
Expand Down

0 comments on commit 1a7b977

Please sign in to comment.