Skip to content

Commit

Permalink
[apple] account for "sim_" prefixes in more configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
dflems committed Dec 16, 2021
1 parent 7455947 commit e4f89f4
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public class AppleConfiguration extends Fragment implements AppleConfigurationAp
public static final String IOS_CPU_PREFIX = "ios_";

// TODO(b/180572694): Remove after platforms based toolchain resolution supported.
/** Prefix for forced iOS simulator cpu values */
public static final String IOS_FORCED_SIMULATOR_CPU_PREFIX = "sim_";
/** Prefix for forced iOS and tvOS simulator cpu values */
public static final String FORCED_SIMULATOR_CPU_PREFIX = "sim_";

/** Default cpu for iOS builds. */
@VisibleForTesting
Expand Down Expand Up @@ -223,22 +223,20 @@ private static String getSingleArchitecture(
// CPU without the ios prefix (e.g. sim_arm64). This parameter is provided in the private method
// so that internal to this class we are able to use both without duplicating retrieval logic.
// TODO(b/180572694): Remove removeSimPrefix parameter once platforms are used instead of CPU
String cpu = getPrefixedAppleCpu(applePlatformType, appleCpus);
if (removeSimPrefix && cpu.startsWith(FORCED_SIMULATOR_CPU_PREFIX)) {
cpu = cpu.substring(FORCED_SIMULATOR_CPU_PREFIX.length());
}
return cpu;
}

private static String getPrefixedAppleCpu(PlatformType applePlatformType, AppleCpus appleCpus) {
if (!Strings.isNullOrEmpty(appleCpus.appleSplitCpu())) {
String cpu = appleCpus.appleSplitCpu();
if (removeSimPrefix && cpu.startsWith(IOS_FORCED_SIMULATOR_CPU_PREFIX)) {
cpu = cpu.substring(IOS_FORCED_SIMULATOR_CPU_PREFIX.length());
}
return cpu;
return appleCpus.appleSplitCpu();
}
switch (applePlatformType) {
case IOS:
{
String cpu = Iterables.getFirst(appleCpus.iosMultiCpus(), appleCpus.iosCpu());
if (removeSimPrefix && cpu.startsWith(IOS_FORCED_SIMULATOR_CPU_PREFIX)) {
cpu = cpu.substring(IOS_FORCED_SIMULATOR_CPU_PREFIX.length());
}
return cpu;
}
return Iterables.getFirst(appleCpus.iosMultiCpus(), appleCpus.iosCpu());
case WATCHOS:
return appleCpus.watchosCpus().get(0);
case TVOS:
Expand Down

0 comments on commit e4f89f4

Please sign in to comment.