forked from swiftlang/swift-package-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatformRegistry.swift
More file actions
36 lines (30 loc) · 1.41 KB
/
Copy pathPlatformRegistry.swift
File metadata and controls
36 lines (30 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
/// A registry for available platforms.
public final class PlatformRegistry {
/// The current registry is hardcoded and static so we can just use
/// a singleton for now.
public static let `default`: PlatformRegistry = .init()
/// The list of known platforms.
public let knownPlatforms: [Platform]
/// The mapping of platforms to their name.
public let platformByName: [String: Platform]
/// Create a registry with the given list of platforms.
init(platforms: [Platform] = PlatformRegistry._knownPlatforms) {
self.knownPlatforms = platforms
self.platformByName = Dictionary(uniqueKeysWithValues: knownPlatforms.map({ ($0.name, $0) }))
}
/// The static list of known platforms.
private static var _knownPlatforms: [Platform] {
return [.macOS, .macCatalyst, .iOS, .tvOS, .watchOS, .visionOS, .linux, .windows, .android, .wasi, .driverKit, .openbsd]
}
}