Skip to content

Commit f4d0922

Browse files
Adjust targetSwift path to include swiftPlatform to identify the toolchain
- Otherwise weird things happen from the EndToEndTests when running tests that then need to re-download a new toolchain on top.
1 parent 72588ac commit f4d0922

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

Sources/SwiftSDKGenerator/Artifacts/DownloadableArtifacts.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ struct DownloadableArtifacts: Sendable {
5454

5555
if hostTriple.os == .linux {
5656
// Amazon Linux 2 is chosen for its best compatibility with all Swift-supported Linux hosts
57-
let linuxArchSuffix =
57+
let hostArchSuffix =
5858
hostTriple.arch == .aarch64 ? "-\(Triple.Arch.aarch64.linuxConventionName)" : ""
5959
self.hostSwift = .init(
6060
remoteURL: versions.swiftDownloadURL(
61-
subdirectory: "amazonlinux2\(linuxArchSuffix)",
62-
platform: "amazonlinux2\(linuxArchSuffix)",
61+
subdirectory: "amazonlinux2\(hostArchSuffix)",
62+
platform: "amazonlinux2\(hostArchSuffix)",
6363
fileExtension: "tar.gz"
6464
),
6565
localPath: paths.artifactsCachePath
@@ -97,7 +97,9 @@ struct DownloadableArtifacts: Sendable {
9797
self.targetSwift = .init(
9898
remoteURL: versions.swiftDownloadURL(),
9999
localPath: paths.artifactsCachePath
100-
.appending("target_swift_\(versions.swiftVersion)_\(targetTriple.triple).tar.gz"),
100+
.appending(
101+
"target_swift_\(versions.swiftVersion)_\(versions.swiftPlatform)_\(targetTriple.archName).tar.gz"
102+
),
101103
isPrebuilt: true
102104
)
103105
}

Sources/SwiftSDKGenerator/PlatformModels/VersionsConfiguration.swift

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,39 @@ public struct VersionsConfiguration: Sendable {
4242
var swiftPlatform: String {
4343
switch self.linuxDistribution {
4444
case let .ubuntu(ubuntu):
45-
return "ubuntu\(ubuntu.version)\(self.linuxArchSuffix)"
45+
return "ubuntu\(ubuntu.version)"
4646
case let .debian(debian):
4747
if debian.version == "11" {
48-
logger.warning(
49-
"Debian 11 selected but not officially supported by Swift, falling back on Ubuntu 20.04 toolchain..."
50-
)
5148
// Ubuntu 20.04 toolchain is binary compatible with Debian 11
52-
return "ubuntu20.04\(self.linuxArchSuffix)"
49+
return "ubuntu20.04"
5350
} else if self.swiftVersion.hasPrefix("5.9") || self.swiftVersion == "5.10" {
54-
logger.warning(
55-
"Debian 12 selected but not officially supported by Swift version, falling back on Ubuntu 22.04 toolchain...",
56-
metadata: ["swiftVersion": .string(self.swiftVersion)]
57-
)
5851
// Ubuntu 22.04 toolchain is binary compatible with Debian 12
59-
return "ubuntu22.04\(self.linuxArchSuffix)"
52+
return "ubuntu22.04"
6053
}
61-
return "debian\(debian.version)\(self.linuxArchSuffix)"
54+
return "debian\(debian.version)"
6255
case let .rhel(rhel):
63-
return "\(rhel.rawValue)\(self.linuxArchSuffix)"
56+
return rhel.rawValue
6457
}
6558
}
6659

60+
var swiftPlatformAndSuffix: String {
61+
return "\(self.swiftPlatform)\(self.linuxArchSuffix)"
62+
}
63+
6764
func swiftDistributionName(platform: String? = nil) -> String {
68-
return "swift-\(self.swiftVersion)-\(platform ?? self.swiftPlatform)"
65+
return
66+
"swift-\(self.swiftVersion)-\(platform ?? self.swiftPlatformAndSuffix)"
6967
}
7068

7169
func swiftDownloadURL(
7270
subdirectory: String? = nil,
7371
platform: String? = nil,
7472
fileExtension: String = "tar.gz"
7573
) -> URL {
76-
let computedPlatform = platform ?? self.swiftPlatform
74+
let computedPlatform = platform ?? self.swiftPlatformAndSuffix
7775
let computedSubdirectory =
78-
subdirectory ?? computedPlatform.replacingOccurrences(of: ".", with: "")
76+
subdirectory
77+
?? computedPlatform.replacingOccurrences(of: ".", with: "")
7978

8079
return URL(
8180
string: """

Tests/SwiftSDKGeneratorTests/EndToEndTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ final class Swift59_DebianEndToEndTests: XCTestCase {
484484
config: config.withLinuxDistributionVersion("12").withArchitecture("x86_64"))
485485
}
486486

487-
// NOTE: the generator does not support building a Debian 11/Debian 12 Swift SDK for
488-
// Swift 5.9.x and 5.10 without a pre-built container, so we do not test this here.
487+
// NOTE: the generator does not support building a Debian 11/Debian 12 Swift SDK with Docker
488+
// for Swift 5.9.x and 5.10 without a pre-built container, so we do not test this here.
489489
}
490490

491491
final class Swift510_DebianEndToEndTests: XCTestCase {
@@ -529,8 +529,8 @@ final class Swift510_DebianEndToEndTests: XCTestCase {
529529
config: config.withLinuxDistributionVersion("11").withArchitecture("x86_64"))
530530
}
531531

532-
// NOTE: the generator does not support building a Debian 11 Swift container automatically,
533-
// so we don't test this scenario.
532+
// NOTE: Debian 11 containers do not exist for Swift, and the generator does not support
533+
// generating this container for you automatically, so we do not test this scenario.
534534
}
535535

536536
final class Swift60_DebianEndToEndTests: XCTestCase {
@@ -574,8 +574,8 @@ final class Swift60_DebianEndToEndTests: XCTestCase {
574574
config: config.withLinuxDistributionVersion("11").withArchitecture("x86_64"))
575575
}
576576

577-
// NOTE: the generator does not support building a Debian 11 Swift container automatically,
578-
// so we don't test this scenario.}
577+
// NOTE: Debian 11 containers do not exist for Swift, and the generator does not support
578+
// generating this container for you automatically, so we do not test this scenario.
579579
}
580580

581581
final class Swift59_RHELEndToEndTests: XCTestCase {

0 commit comments

Comments
 (0)