File tree Expand file tree Collapse file tree 3 files changed +11
-29
lines changed
Expand file tree Collapse file tree 3 files changed +11
-29
lines changed Original file line number Diff line number Diff line change @@ -382,13 +382,7 @@ public struct Linux: Platform {
382382 }
383383
384384 public func getExecutableName( ) -> String {
385- #if arch(x86_64)
386- let arch = " x86_64 "
387- #elseif arch(arm64)
388- let arch = " aarch64 "
389- #else
390- fatalError ( " Unsupported processor architecture " )
391- #endif
385+ let arch = cpuArch
392386
393387 return " swiftly- \( arch) -unknown-linux-gnu "
394388 }
Original file line number Diff line number Diff line change @@ -295,17 +295,7 @@ public struct SwiftlyHTTPClient {
295295 limit: Int ? = nil ,
296296 filter: ( ( ToolchainVersion . StableRelease ) -> Bool ) ? = nil
297297 ) async throws -> [ ToolchainVersion . StableRelease ] {
298- let arch = if a == nil {
299- #if arch(x86_64)
300- " x86_64 "
301- #elseif arch(arm64)
302- " aarch64 "
303- #else
304- #error("Unsupported processor architecture")
305- #endif
306- } else {
307- a!
308- }
298+ let arch = a ?? cpuArch
309299
310300 let url = " https://www.swift.org/api/v1/install/releases.json "
311301 let swiftOrgReleases : [ SwiftOrgRelease ] = try await self . getFromJSON ( url: url, type: [ SwiftOrgRelease ] . self)
@@ -359,17 +349,7 @@ public struct SwiftlyHTTPClient {
359349 limit: Int ? = nil ,
360350 filter: ( ( ToolchainVersion . Snapshot ) -> Bool ) ? = nil
361351 ) async throws -> [ ToolchainVersion . Snapshot ] {
362- let arch = if a == nil {
363- #if arch(x86_64)
364- " x86_64 "
365- #elseif arch(arm64)
366- " aarch64 "
367- #else
368- #error("Unsupported processor architecture")
369- #endif
370- } else {
371- a!
372- }
352+ let arch = a ?? cpuArch
373353
374354 let platformName = if platform. name == PlatformDefinition . macOS. name {
375355 " macos "
Original file line number Diff line number Diff line change @@ -51,3 +51,11 @@ public func readLine(prompt: String) -> String? {
5151 }
5252 return provider. readLine ( )
5353}
54+
55+ #if arch(x86_64)
56+ public let cpuArch = " x86_64 "
57+ #elseif arch(arm64)
58+ public let cpuArch = " aarch64 "
59+ #else
60+ #error("Unsupported processor architecture")
61+ #endif
You can’t perform that action at this time.
0 commit comments