Skip to content

Commit ce61164

Browse files
Googlercopybara-github
authored andcommitted
Create new watchos_device_arm64 architecture
PiperOrigin-RevId: 478612896 Change-Id: Ice91d2382dc971ebada6efe0be71cdfdb8f2ff69
1 parent f63bb58 commit ce61164

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@ public enum ApplePlatform implements ApplePlatformApi {
4141
WATCHOS_SIMULATOR("watchos_simulator", "WatchSimulator", PlatformType.WATCHOS, false),
4242
CATALYST("catalyst", "MacOSX", PlatformType.CATALYST, true);
4343

44-
// TODO(b/180572694): Remove ios_sim_arm64 after platforms based toolchain resolution supported.
4544
private static final ImmutableSet<String> IOS_SIMULATOR_TARGET_CPUS =
4645
ImmutableSet.of("ios_x86_64", "ios_i386", "ios_sim_arm64");
4746
private static final ImmutableSet<String> IOS_DEVICE_TARGET_CPUS =
4847
ImmutableSet.of("ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s", "ios_arm64e");
4948
private static final ImmutableSet<String> WATCHOS_SIMULATOR_TARGET_CPUS =
5049
ImmutableSet.of("watchos_i386", "watchos_x86_64", "watchos_arm64");
5150
private static final ImmutableSet<String> WATCHOS_DEVICE_TARGET_CPUS =
52-
ImmutableSet.of("watchos_armv7k", "watchos_arm64_32");
51+
ImmutableSet.of("watchos_armv7k", "watchos_arm64_32", "watchos_device_arm64");
5352
private static final ImmutableSet<String> TVOS_SIMULATOR_TARGET_CPUS =
5453
ImmutableSet.of("tvos_x86_64", "tvos_sim_arm64");
5554
private static final ImmutableSet<String> TVOS_DEVICE_TARGET_CPUS =

0 commit comments

Comments
 (0)