Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit 5444652

Browse files
LcsmarcalLucas Marçal
andauthored
[Apple] Fix iPhone simulator arm64 swift triple (#2621)
* Fix iPhoneSimulator arm64 swift triplet * fix unit tests * Empty commit to retrigger CI * fix WatchSimulator architectures Co-authored-by: Lucas Marçal <lucas.marcal@ifood.com.br>
1 parent ea66748 commit 5444652

9 files changed

Lines changed: 45 additions & 32 deletions

File tree

src/com/facebook/buck/apple/AppleToolchainDescription.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ public BuildRule createBuildRule(
130130
args.getArchitecture(),
131131
"apple",
132132
applePlatform.getSwiftName().orElse(applePlatform.getName()),
133-
args.getMinVersion());
133+
args.getMinVersion(),
134+
applePlatform.getIsSimulator());
134135
Optional<SwiftPlatform> swiftPlatform =
135136
swiftToolchainRule
136137
.map(SwiftToolchainBuildRule.class::cast)

src/com/facebook/buck/apple/toolchain/ApplePlatform.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public abstract class ApplePlatform implements Comparable<ApplePlatform>, AddsTo
4343
ImmutableApplePlatform.builder()
4444
.setName("iphonesimulator")
4545
.setSwiftName("ios")
46-
.setArchitectures(ImmutableList.of("i386", "x86_64"))
46+
.setArchitectures(ImmutableList.of("i386", "x86_64", "arm64"))
4747
.setMinVersionFlagPrefix("-mios-simulator-version-min=")
4848
// only used for legacy watch apps
4949
.setStubBinaryPath(Optional.of("Library/Application Support/WatchKit/WK"))
@@ -59,7 +59,7 @@ public abstract class ApplePlatform implements Comparable<ApplePlatform>, AddsTo
5959
public static final ApplePlatform WATCHSIMULATOR =
6060
ImmutableApplePlatform.builder()
6161
.setName("watchsimulator")
62-
.setArchitectures(ImmutableList.of("i386", "x86_64"))
62+
.setArchitectures(ImmutableList.of("i386", "x86_64", "arm64"))
6363
.setMinVersionFlagPrefix("-mwatchos-simulator-version-min=")
6464
.setStubBinaryPath(Optional.of("Library/Application Support/WatchKit/WK"))
6565
.build();
@@ -73,14 +73,14 @@ public abstract class ApplePlatform implements Comparable<ApplePlatform>, AddsTo
7373
public static final ApplePlatform APPLETVSIMULATOR =
7474
ImmutableApplePlatform.builder()
7575
.setName("appletvsimulator")
76-
.setArchitectures(ImmutableList.of("x86_64"))
76+
.setArchitectures(ImmutableList.of("arm64", "x86_64"))
7777
.setMinVersionFlagPrefix("-mtvos-simulator-version-min=")
7878
.setSwiftName("tvos")
7979
.build();
8080
public static final ApplePlatform MACOSX =
8181
ImmutableApplePlatform.builder()
8282
.setName("macosx")
83-
.setArchitectures(ImmutableList.of("i386", "x86_64"))
83+
.setArchitectures(ImmutableList.of("i386", "x86_64", "arm64"))
8484
.setAppIncludesFrameworks(true)
8585
.build();
8686
public static final ApplePlatform DRIVERKIT =
@@ -144,6 +144,10 @@ public ApplePlatformType getType() {
144144
return ApplePlatformType.of(getName());
145145
}
146146

147+
public boolean getIsSimulator() {
148+
return isSimulator(getName());
149+
}
150+
147151
public static boolean needsCodeSign(String name) {
148152
return name.startsWith(IPHONEOS.getName())
149153
|| name.startsWith(IPHONESIMULATOR.getName())

src/com/facebook/buck/apple/toolchain/impl/AppleCxxPlatforms.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ public static AppleCxxPlatform buildWithXcodeToolFinder(
478478
targetArchitecture,
479479
"apple",
480480
applePlatform.getSwiftName().orElse(applePlatform.getName()),
481-
minVersion),
481+
minVersion,
482+
applePlatform.getIsSimulator()),
482483
version,
483484
targetSdk,
484485
swiftSdkPathsBuilder.build(),

src/com/facebook/buck/swift/toolchain/SwiftTargetTriple.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,26 @@ public abstract class SwiftTargetTriple implements AddsToRuleKey {
4040
@AddToRuleKey
4141
public abstract String getTargetSdkVersion();
4242

43+
@AddToRuleKey
44+
public abstract Boolean getIsSimulator();
45+
4346
public String getTriple() {
44-
return getArchitecture() + "-" + getVendor() + "-" + getPlatformName() + getTargetSdkVersion();
47+
String triple = getArchitecture() + "-" + getVendor() + "-" + getPlatformName() + getTargetSdkVersion();
48+
if(getIsSimulator()) {
49+
triple = triple + "-simulator";
50+
}
51+
return triple;
4552
}
4653

4754
public static SwiftTargetTriple of(
48-
String architecture, String vendor, String platformName, String targetSdkVersion) {
49-
return ImmutableSwiftTargetTriple.of(architecture, vendor, platformName, targetSdkVersion);
55+
String architecture, String vendor, String platformName, String targetSdkVersion, Boolean isSimulator) {
56+
return ImmutableSwiftTargetTriple.of(architecture, vendor, platformName, targetSdkVersion, isSimulator);
5057
}
5158

5259
public SwiftTargetTriple withTargetSdkVersion(String targetSdkVersion) {
5360
if (targetSdkVersion.equals(getTargetSdkVersion())) {
5461
return this;
5562
}
56-
return of(getArchitecture(), getVendor(), getPlatformName(), targetSdkVersion);
63+
return of(getArchitecture(), getVendor(), getPlatformName(), targetSdkVersion, getIsSimulator());
5764
}
5865
}

test/com/facebook/buck/apple/AppleBinaryIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ public void testAppleBinaryBuildsFatBinariesWithSwift() throws Exception {
15301530
workspace.setUp();
15311531
BuildTarget target =
15321532
BuildTargetFactory.newInstance(
1533-
"//:DemoAppBinary#iphonesimulator-i386,iphonesimulator-x86_64,no-linkermap");
1533+
"//:DemoAppBinary#iphonesimulator-i386,iphonesimulator-x86_64,iphonesimulator-arm64,no-linkermap");
15341534
workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
15351535

15361536
Path output =
@@ -1541,7 +1541,7 @@ public void testAppleBinaryBuildsFatBinariesWithSwift() throws Exception {
15411541
workspace.runCommand("file", output.toString()).getStdout().get(),
15421542
containsString("executable"));
15431543
ProcessExecutor.Result lipoVerifyResult =
1544-
workspace.runCommand("lipo", output.toString(), "-verify_arch", "i386", "x86_64");
1544+
workspace.runCommand("lipo", output.toString(), "-verify_arch", "i386", "x86_64", "arm64");
15451545
assertEquals(lipoVerifyResult.getStderr().orElse(""), 0, lipoVerifyResult.getExitCode());
15461546
}
15471547

test/com/facebook/buck/apple/toolchain/impl/AppleCxxPlatformsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ public void checkSwiftPlatformUsesCorrectMinTargetSdk() {
11991199
assertThat(swiftc, instanceOf(VersionedTool.class));
12001200
assertThat(
12011201
swiftPlatform.getSwiftTarget(),
1202-
equalTo(SwiftTargetTriple.of("i386", "apple", "ios", "7.0")));
1202+
equalTo(SwiftTargetTriple.of("i386", "apple", "ios", "7.0", false)));
12031203
}
12041204

12051205
@Test

test/com/facebook/buck/apple/toolchain/impl/AppleSdkDiscoveryTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ public void shouldResolveSdkVersionConflicts() throws IOException {
104104
.setName("macosx")
105105
.setVersion("10.9")
106106
.setApplePlatform(ApplePlatform.MACOSX)
107-
.addArchitectures("i386", "x86_64")
107+
.addArchitectures("i386", "x86_64", "arm64")
108108
.addAllToolchains(toolchains.values())
109109
.build();
110110
AppleSdk macosxDebugSdk =
111111
AppleSdk.builder()
112112
.setName("macosx-Debug")
113113
.setVersion("10.9")
114114
.setApplePlatform(ApplePlatform.MACOSX)
115-
.addArchitectures("i386", "x86_64")
115+
.addArchitectures("i386", "x86_64", "arm64")
116116
.addAllToolchains(toolchains.values())
117117
.build();
118118
AppleSdkPaths macosxReleasePaths =
@@ -167,7 +167,7 @@ public void shouldFindPlatformsInExtraPlatformDirectories() throws IOException {
167167
.setName("macosx10.9")
168168
.setVersion("10.9")
169169
.setApplePlatform(ApplePlatform.MACOSX)
170-
.addArchitectures("i386", "x86_64")
170+
.addArchitectures("i386", "x86_64", "arm64")
171171
.addAllToolchains(toolchains.values())
172172
.build();
173173
AppleSdkPaths macosx109Paths =
@@ -210,7 +210,7 @@ public void ignoresInvalidExtraPlatformDirectories() throws IOException {
210210
.setName("macosx10.9")
211211
.setVersion("10.9")
212212
.setApplePlatform(ApplePlatform.MACOSX)
213-
.addArchitectures("i386", "x86_64")
213+
.addArchitectures("i386", "x86_64", "arm64")
214214
.addAllToolchains(toolchains.values())
215215
.build();
216216
AppleSdkPaths macosx109Paths =
@@ -284,7 +284,7 @@ public void shouldIgnoreSdkWithBadSymlink() throws Exception {
284284
.setName("macosx10.9")
285285
.setVersion("10.9")
286286
.setApplePlatform(ApplePlatform.MACOSX)
287-
.addArchitectures("i386", "x86_64")
287+
.addArchitectures("i386", "x86_64", "arm64")
288288
.addAllToolchains(toolchains.values())
289289
.build();
290290
AppleSdkPaths macosx109Paths =
@@ -326,7 +326,7 @@ public void appleSdkPathsBuiltFromDirectory() throws Exception {
326326
.setName("macosx10.9")
327327
.setVersion("10.9")
328328
.setApplePlatform(ApplePlatform.MACOSX)
329-
.addArchitectures("i386", "x86_64")
329+
.addArchitectures("i386", "x86_64", "arm64")
330330
.addToolchains(getDefaultToolchain(root))
331331
.build();
332332
AppleSdkPaths macosx109Paths =
@@ -358,7 +358,7 @@ public void appleSdkPathsBuiltFromDirectory() throws Exception {
358358
.setName("iphonesimulator8.0")
359359
.setVersion("8.0")
360360
.setApplePlatform(ApplePlatform.IPHONESIMULATOR)
361-
.addArchitectures("i386", "x86_64")
361+
.addArchitectures("i386", "x86_64", "arm64")
362362
.addToolchains(getDefaultToolchain(root))
363363
.build();
364364
AppleSdkPaths iphonesimulator80Paths =
@@ -392,7 +392,7 @@ public void appleSdkPathsBuiltFromDirectory() throws Exception {
392392
.setName("watchsimulator2.0")
393393
.setVersion("2.0")
394394
.setApplePlatform(ApplePlatform.WATCHSIMULATOR)
395-
.addArchitectures("i386", "x86_64")
395+
.addArchitectures("i386", "x86_64", "arm64")
396396
.addToolchains(getDefaultToolchain(root))
397397
.build();
398398
AppleSdkPaths watchsimulator20Paths =
@@ -425,7 +425,7 @@ public void appleSdkPathsBuiltFromDirectory() throws Exception {
425425
.setName("appletvsimulator9.1")
426426
.setVersion("9.1")
427427
.setApplePlatform(ApplePlatform.APPLETVSIMULATOR)
428-
.addArchitectures("x86_64")
428+
.addArchitectures("x86_64", "arm64")
429429
.addToolchains(getDefaultToolchain(root))
430430
.build();
431431
AppleSdkPaths appletvsimulator91Paths =
@@ -501,7 +501,7 @@ public void multipleAppleSdkPathsPerPlatformBuiltFromDirectory() throws Exceptio
501501
.setName("macosx10.9")
502502
.setVersion("10.9")
503503
.setApplePlatform(ApplePlatform.MACOSX)
504-
.addArchitectures("i386", "x86_64")
504+
.addArchitectures("i386", "x86_64", "arm64")
505505
.addToolchains(getDefaultToolchain(root))
506506
.build();
507507
AppleSdkPaths macosx109Paths =
@@ -533,7 +533,7 @@ public void multipleAppleSdkPathsPerPlatformBuiltFromDirectory() throws Exceptio
533533
.setName("iphonesimulator8.0")
534534
.setVersion("8.0")
535535
.setApplePlatform(ApplePlatform.IPHONESIMULATOR)
536-
.addArchitectures("i386", "x86_64")
536+
.addArchitectures("i386", "x86_64", "arm64")
537537
.addToolchains(getDefaultToolchain(root))
538538
.build();
539539
AppleSdkPaths iphonesimulator80Paths =
@@ -567,7 +567,7 @@ public void multipleAppleSdkPathsPerPlatformBuiltFromDirectory() throws Exceptio
567567
.setName("iphonesimulator8.1")
568568
.setVersion("8.1")
569569
.setApplePlatform(ApplePlatform.IPHONESIMULATOR)
570-
.addArchitectures("i386", "x86_64")
570+
.addArchitectures("i386", "x86_64", "arm64")
571571
.addToolchains(getDefaultToolchain(root))
572572
.build();
573573
AppleSdkPaths iphonesimulator81Paths =
@@ -625,7 +625,7 @@ public void shouldDiscoverRealSdkThroughAbsoluteSymlink() throws IOException {
625625
.setName("macosx10.9")
626626
.setVersion("10.9")
627627
.setApplePlatform(ApplePlatform.MACOSX)
628-
.addArchitectures("i386", "x86_64")
628+
.addArchitectures("i386", "x86_64", "arm64")
629629
.addAllToolchains(toolchains.values())
630630
.build();
631631
AppleSdkPaths macosx109Paths =
@@ -751,7 +751,7 @@ public void overrideToolchains() throws IOException {
751751
.setName("macosx10.9")
752752
.setVersion("10.9")
753753
.setApplePlatform(ApplePlatform.MACOSX)
754-
.addArchitectures("i386", "x86_64")
754+
.addArchitectures("i386", "x86_64", "arm64")
755755
.addAllToolchains(ImmutableList.of(overrideToolchain1, overrideToolchain2))
756756
.build();
757757
AppleSdkPaths macosx109Paths =

test/com/facebook/buck/swift/SwiftNativeLinkableGroupTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void testStaticLinkerFlagsOnMobile() {
111111
swiftcTool,
112112
Optional.of(swiftStdTool),
113113
true,
114-
SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3"));
114+
SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3", false));
115115

116116
ImmutableList.Builder<Arg> staticArgsBuilder = ImmutableList.builder();
117117
SwiftRuntimeNativeLinkableGroup.populateLinkerArguments(
@@ -152,7 +152,7 @@ public void testStaticLinkerFlagsOnMac() {
152152
swiftcTool,
153153
Optional.of(swiftStdTool),
154154
true,
155-
SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3"));
155+
SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3", false));
156156

157157
ImmutableList.Builder<Arg> sharedArgsBuilder = ImmutableList.builder();
158158
SwiftRuntimeNativeLinkableGroup.populateLinkerArguments(

test/com/facebook/buck/swift/toolchain/impl/SwiftPlatformFactoryIntegrationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void setUp() {
8686
@Test
8787
public void testBuildSwiftPlatformWithEmptyToolchainPaths() throws IOException {
8888
Path developerDir = tmp.newFolder("Developer");
89-
SwiftTargetTriple triple = SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3");
89+
SwiftTargetTriple triple = SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3", false);
9090
SwiftPlatform swiftPlatform =
9191
SwiftPlatformFactory.build(
9292
createAppleSdk(),
@@ -113,7 +113,7 @@ public void testBuildSwiftPlatformWithNonEmptyLookupPathWithoutTools() throws IO
113113
swiftcTool,
114114
Optional.of(swiftStdTool),
115115
true,
116-
SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3"));
116+
SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3", false));
117117
assertThat(swiftPlatform.getSwiftRuntimePathsForBundling(), empty());
118118
assertThat(swiftPlatform.getSwiftStaticRuntimePaths(), empty());
119119
}
@@ -136,7 +136,7 @@ public void testBuildSwiftPlatformWithNonEmptyLookupPathWithTools() throws IOExc
136136
swiftcTool,
137137
Optional.of(swiftStdTool),
138138
true,
139-
SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3"));
139+
SwiftTargetTriple.of("x86_64", "apple", "ios", "9.3", false));
140140
assertThat(swiftPlatform.getSwiftRuntimePathsForBundling(), hasSize(1));
141141
assertThat(swiftPlatform.getSwiftStaticRuntimePaths(), hasSize(2));
142142
}

0 commit comments

Comments
 (0)