@@ -56,7 +56,7 @@ func buildSDK(_ logger: Logger, scratchPath: String, withArguments runArguments:
56
56
logger [ metadataKey: " runArguments " ] = " \" \( runArguments) \" "
57
57
logger [ metadataKey: " scratchPath " ] = " \( scratchPath) "
58
58
59
- logger. info ( " Building SDK " )
59
+ logger. info ( " Building Swift SDK " )
60
60
61
61
var packageDirectory = FilePath ( #filePath)
62
62
packageDirectory. removeLastComponent ( )
@@ -65,7 +65,7 @@ func buildSDK(_ logger: Logger, scratchPath: String, withArguments runArguments:
65
65
let generatorOutput = try await Shell . readStdout (
66
66
" cd \( packageDirectory) && swift run --scratch-path \" \( scratchPath) \" swift-sdk-generator make-linux-sdk \( runArguments) "
67
67
)
68
- logger. info ( " Finished building SDK " )
68
+ logger. info ( " Finished building Swift SDK " )
69
69
70
70
let installCommand = try XCTUnwrap ( generatorOutput. split ( separator: " \n " ) . first {
71
71
$0. contains ( " swift experimental-sdk install " )
@@ -76,16 +76,16 @@ func buildSDK(_ logger: Logger, scratchPath: String, withArguments runArguments:
76
76
) . stem
77
77
logger [ metadataKey: " bundleName " ] = " \( bundleName) "
78
78
79
- logger. info ( " Checking installed SDKs " )
79
+ logger. info ( " Checking installed Swift SDKs " )
80
80
let installedSDKs = try await Shell . readStdout ( " swift experimental-sdk list " ) . components ( separatedBy: " \n " )
81
81
82
82
// Make sure this bundle hasn't been installed already.
83
83
if installedSDKs. contains ( bundleName) {
84
- logger. info ( " Removing existing SDK " )
84
+ logger. info ( " Removing existing Swift SDK " )
85
85
try await Shell . run ( " swift experimental-sdk remove \( bundleName) " )
86
86
}
87
87
88
- logger. info ( " Installing new SDK " )
88
+ logger. info ( " Installing new Swift SDK " )
89
89
let installOutput = try await Shell . readStdout ( String ( installCommand) )
90
90
XCTAssertTrue ( installOutput. contains ( " successfully installed " ) )
91
91
@@ -152,15 +152,25 @@ struct SDKConfiguration {
152
152
var linuxDistributionVersion : String
153
153
var architecture : String
154
154
var withDocker : Bool
155
+ var containerImageSuffix : String ?
155
156
156
- var bundleName : String { " \( linuxDistributionName) _ \( linuxDistributionVersion) _ \( architecture) _ \( swiftVersion) -RELEASE \( withDocker ? " _with-docker " : " " ) " }
157
+ var bundleName : String {
158
+ let sdkPrefix = containerImageSuffix ?? " \( linuxDistributionName) _ \( linuxDistributionVersion) "
159
+ return " \( sdkPrefix) _ \( architecture) _ \( swiftVersion) -RELEASE \( withDocker ? " _with-docker " : " " ) "
160
+ }
157
161
158
162
func withDocker( _ enabled: Bool = true ) -> SDKConfiguration {
159
163
var res = self
160
164
res. withDocker = enabled
161
165
return res
162
166
}
163
167
168
+ func withContainerImageSuffix( _ containerImageSuffix: String ) -> SDKConfiguration {
169
+ var res = self
170
+ res. containerImageSuffix = containerImageSuffix
171
+ return res
172
+ }
173
+
164
174
func withArchitecture( _ arch: String ) -> SDKConfiguration {
165
175
var res = self
166
176
res. architecture = arch
@@ -173,10 +183,17 @@ struct SDKConfiguration {
173
183
}
174
184
175
185
var sdkGeneratorArguments : String {
186
+ // Build the container image tag
187
+ var containerImage : String ? = nil
188
+ if let containerImageSuffix {
189
+ containerImage = " swift: \( swiftVersion) - \( containerImageSuffix) "
190
+ }
191
+
176
192
return [
177
193
" --sdk-name \( bundleName) " ,
178
194
" --host-toolchain " ,
179
195
withDocker ? " --with-docker " : nil ,
196
+ containerImage != nil ? " --from-container-image " : nil , containerImage,
180
197
" --swift-version \( swiftVersion) -RELEASE " ,
181
198
testLinuxSwiftSDKs ? " --host \( hostArch!) -unknown-linux-gnu " : nil ,
182
199
" --target \( architecture) -unknown-linux-gnu " ,
@@ -403,11 +420,19 @@ final class Swift59_RHELEndToEndTests: XCTestCase {
403
420
)
404
421
405
422
func testAarch64FromContainer( ) async throws {
406
- try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) . withDocker ( ) )
423
+ try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) )
407
424
}
408
425
409
426
func testX86_64FromContainer( ) async throws {
410
- try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) . withDocker ( ) )
427
+ try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) )
428
+ }
429
+
430
+ func testAmazonLinux2Aarch64FromContainer( ) async throws {
431
+ try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) . withContainerImageSuffix ( " amazonlinux2 " ) )
432
+ }
433
+
434
+ func testAmazonLinux2X86_64FromContainer( ) async throws {
435
+ try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) . withContainerImageSuffix ( " amazonlinux2 " ) )
411
436
}
412
437
}
413
438
@@ -421,11 +446,27 @@ final class Swift510_RHELEndToEndTests: XCTestCase {
421
446
)
422
447
423
448
func testAarch64FromContainer( ) async throws {
424
- try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) . withDocker ( ) )
449
+ try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) )
425
450
}
426
451
427
452
func testX86_64FromContainer( ) async throws {
428
- try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) . withDocker ( ) )
453
+ try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) )
454
+ }
455
+
456
+ func testAmazonLinux2Aarch64FromContainer( ) async throws {
457
+ try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) . withContainerImageSuffix ( " amazonlinux2 " ) )
458
+ }
459
+
460
+ func testAmazonLinux2X86_64FromContainer( ) async throws {
461
+ try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) . withContainerImageSuffix ( " amazonlinux2 " ) )
462
+ }
463
+
464
+ func testFedora39Aarch64FromContainer( ) async throws {
465
+ try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) . withContainerImageSuffix ( " fedora39 " ) )
466
+ }
467
+
468
+ func testFedora39X86_64FromContainer( ) async throws {
469
+ try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) . withContainerImageSuffix ( " fedora39 " ) )
429
470
}
430
471
}
431
472
@@ -439,10 +480,26 @@ final class Swift60_RHELEndToEndTests: XCTestCase {
439
480
)
440
481
441
482
func testAarch64FromContainer( ) async throws {
442
- try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) . withDocker ( ) )
483
+ try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) )
443
484
}
444
485
445
486
func testX86_64FromContainer( ) async throws {
446
- try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) . withDocker ( ) )
487
+ try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) )
488
+ }
489
+
490
+ func testAmazonLinux2Aarch64FromContainer( ) async throws {
491
+ try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) . withContainerImageSuffix ( " amazonlinux2 " ) )
492
+ }
493
+
494
+ func testAmazonLinux2X86_64FromContainer( ) async throws {
495
+ try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) . withContainerImageSuffix ( " amazonlinux2 " ) )
496
+ }
497
+
498
+ func testFedora39Aarch64FromContainer( ) async throws {
499
+ try await buildTestcases ( config: config. withArchitecture ( " aarch64 " ) . withContainerImageSuffix ( " fedora39 " ) )
500
+ }
501
+
502
+ func testFedora39X86_64FromContainer( ) async throws {
503
+ try await buildTestcases ( config: config. withArchitecture ( " x86_64 " ) . withContainerImageSuffix ( " fedora39 " ) )
447
504
}
448
505
}
0 commit comments