Skip to content

Commit a5ad6f7

Browse files
committed
Move PlatformRegistry to PackageLoading module
1 parent d861182 commit a5ad6f7

File tree

3 files changed

+37
-25
lines changed

3 files changed

+37
-25
lines changed

Sources/PackageLoading/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ add_library(PackageLoading
1414
ModuleMapGenerator.swift
1515
PackageBuilder.swift
1616
PackageDescription4Loader.swift
17+
PlatformRegistry.swift
1718
Target+PkgConfig.swift
1819
TargetSourcesBuilder.swift
1920
ToolsVersionLoader.swift
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2018 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
import PackageModel
12+
13+
/// A registry for available platforms.
14+
public final class PlatformRegistry {
15+
16+
/// The current registery is hardcoded and static so we can just use
17+
/// a singleton for now.
18+
public static let `default`: PlatformRegistry = .init()
19+
20+
/// The list of known platforms.
21+
public let knownPlatforms: [Platform]
22+
23+
/// The mapping of platforms to their name.
24+
public let platformByName: [String: Platform]
25+
26+
/// Create a registry with the given list of platforms.
27+
init(platforms: [Platform] = PlatformRegistry._knownPlatforms) {
28+
self.knownPlatforms = platforms
29+
self.platformByName = Dictionary(uniqueKeysWithValues: knownPlatforms.map({ ($0.name, $0) }))
30+
}
31+
32+
/// The static list of known platforms.
33+
private static var _knownPlatforms: [Platform] {
34+
return [.macOS, .iOS, .tvOS, .watchOS, .linux, .windows, .android, .wasi]
35+
}
36+
}

Sources/PackageModel/Platform.swift

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,6 @@
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
1010

11-
/// A registry for available platforms.
12-
public final class PlatformRegistry {
13-
14-
/// The current registery is hardcoded and static so we can just use
15-
/// a singleton for now.
16-
public static let `default`: PlatformRegistry = .init()
17-
18-
/// The list of known platforms.
19-
public let knownPlatforms: [Platform]
20-
21-
/// The mapping of platforms to their name.
22-
public let platformByName: [String: Platform]
23-
24-
/// Create a registry with the given list of platforms.
25-
init(platforms: [Platform] = PlatformRegistry._knownPlatforms) {
26-
self.knownPlatforms = platforms
27-
self.platformByName = Dictionary(uniqueKeysWithValues: knownPlatforms.map({ ($0.name, $0) }))
28-
}
29-
30-
/// The static list of known platforms.
31-
private static var _knownPlatforms: [Platform] {
32-
return [.macOS, .iOS, .tvOS, .watchOS, .linux, .windows, .android, .wasi]
33-
}
34-
}
35-
3611
/// Represents a platform.
3712
public struct Platform: Equatable, Hashable, Codable {
3813
/// The name of the platform.

0 commit comments

Comments
 (0)