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 Feb 2, 2022
1 parent 2a44fae commit ad4b87d
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public class AppleConfiguration extends Fragment implements AppleConfigurationAp
private static final String MACOS_CPU_PREFIX = "darwin_";

// 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 @@ -229,25 +229,24 @@ private static String getSingleArchitecture(
// The removeSimPrefix argument is necessary due to a simulator and device both using arm64
// architecture. In the case of Starlark asking for the architecture, we should return the
// actual architecture (arm64) but in other cases in this class what we actually want is the
// 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.
// CPU without the ios/tvos 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 ad4b87d

Please sign in to comment.