Skip to content

Commit 0466fe9

Browse files
committed
[pkg-config] Lazily compute current platform
1 parent 22954af commit 0466fe9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Sources/Build/misc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ extension SystemPackageProvider {
189189
}
190190

191191
var isAvailable: Bool {
192-
guard let platform = Platform.currentPlatform() else { return false }
192+
guard let platform = Platform.currentPlatform else { return false }
193193
switch self {
194194
case .Brew(_):
195195
if case .Darwin = platform {

Sources/Utility/Platform.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public enum Platform {
1818
case Debian
1919
}
2020

21-
public static func currentPlatform() -> Platform? {
21+
// Lazily return current platform.
22+
public static var currentPlatform = Platform.findCurrentPlatform()
23+
private static func findCurrentPlatform() -> Platform? {
2224
guard let uname = try? popen(["uname"]).chomp().lowercased() else { return nil }
2325
switch uname {
2426
case "darwin":

0 commit comments

Comments
 (0)