@@ -75,9 +75,11 @@ public class AppleConfiguration extends Fragment implements AppleConfigurationAp
7575 /** Prefix for macOS cpu values */
7676 private static final String MACOS_CPU_PREFIX = "darwin_" ;
7777
78- // TODO(b/180572694): Remove after platforms based toolchain resolution supported.
79- /** Prefix for forced iOS and tvOS simulator cpu values */
80- public static final String FORCED_SIMULATOR_CPU_PREFIX = "sim_" ;
78+ /** Prefix for simulator environment cpu values */
79+ public static final String SIMULATOR_ENVIRONMENT_CPU_PREFIX = "sim_" ;
80+
81+ /** Prefix for device environment cpu values */
82+ public static final String DEVICE_ENVIRONMENT_CPU_PREFIX = "device_" ;
8183
8284 /** Default cpu for iOS builds. */
8385 @ VisibleForTesting
@@ -222,21 +224,19 @@ public static ImmutableMap<String, String> getXcodeVersionEnv(DottedVersion xcod
222224 */
223225 @ Override
224226 public String getSingleArchitecture () {
225- return getSingleArchitecture (applePlatformType , appleCpus , /* removeSimPrefix = */ true );
227+ return getSingleArchitecture (applePlatformType , appleCpus , /* removeEnvironmentPrefix = */ true );
226228 }
227229
228230 private static String getSingleArchitecture (
229- PlatformType applePlatformType , AppleCpus appleCpus , boolean removeSimPrefix ) {
230- // The removeSimPrefix argument is necessary due to a simulator and device both using arm64
231- // architecture. In the case of Starlark asking for the architecture, we should return the
232- // actual architecture (arm64) but in other cases in this class what we actually want is the
233- // CPU without the ios/tvos prefix (e.g. sim_arm64). This parameter is provided in the private
234- // method so that internal to this class we are able to use both without duplicating retrieval
235- // logic.
236- // TODO(b/180572694): Remove removeSimPrefix parameter once platforms are used instead of CPU
231+ PlatformType applePlatformType , AppleCpus appleCpus , boolean removeEnvironmentPrefix ) {
232+ // The removeEnvironmentPrefix argument is used to remove the environment data from the CPU
233+ // - e.g. whether the target CPU is for simulator, device or catalyst. For older CPUs,
234+ // no environment may be provided.
237235 String cpu = getPrefixedAppleCpu (applePlatformType , appleCpus );
238- if (removeSimPrefix && cpu .startsWith (FORCED_SIMULATOR_CPU_PREFIX )) {
239- cpu = cpu .substring (FORCED_SIMULATOR_CPU_PREFIX .length ());
236+ if (removeEnvironmentPrefix && cpu .startsWith (SIMULATOR_ENVIRONMENT_CPU_PREFIX )) {
237+ cpu = cpu .substring (SIMULATOR_ENVIRONMENT_CPU_PREFIX .length ());
238+ } else if (removeEnvironmentPrefix && cpu .startsWith (DEVICE_ENVIRONMENT_CPU_PREFIX )) {
239+ cpu = cpu .substring (DEVICE_ENVIRONMENT_CPU_PREFIX .length ());
240240 }
241241 return cpu ;
242242 }
@@ -319,7 +319,7 @@ public List<String> getMultiArchitectures(PlatformType platformType) {
319319 public ApplePlatform getSingleArchPlatform () {
320320 return ApplePlatform .forTarget (
321321 applePlatformType ,
322- getSingleArchitecture (applePlatformType , appleCpus , /* removeSimPrefix = */ false ));
322+ getSingleArchitecture (applePlatformType , appleCpus , /* removeEnvironmentPrefix = */ false ));
323323 }
324324
325325 /**
@@ -384,7 +384,7 @@ public static AppleBitcodeMode getAppleBitcodeMode(
384384 AppleCpus appleCpus ,
385385 EnumMap <ApplePlatform .PlatformType , AppleBitcodeMode > platformBitcodeModes ) {
386386 String architecture =
387- getSingleArchitecture (applePlatformType , appleCpus , /* removeSimPrefix = */ false );
387+ getSingleArchitecture (applePlatformType , appleCpus , /* removeEnvironmentPrefix = */ false );
388388 String cpuString = ApplePlatform .cpuStringForTarget (applePlatformType , architecture );
389389 if (ApplePlatform .isApplePlatform (cpuString )) {
390390 ApplePlatform platform = ApplePlatform .forTarget (applePlatformType , architecture );
0 commit comments