Skip to content

Commit 1907218

Browse files
committed
Add more missing availability annotations and clean up ifdefs
1 parent 866b28a commit 1907218

19 files changed

+41
-39
lines changed

Sources/TSCBasic/HashAlgorithms.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public struct SHA256: HashAlgorithm {
174174
}
175175

176176
/// Wraps CryptoKit.SHA256 to provide a HashAlgorithm conformance to it.
177-
@available(macOS 10.15, iOS 13, *)
177+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
178178
public struct CryptoKitSHA256: HashAlgorithm {
179179
public init() {
180180
}

Sources/TSCBasic/Process.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public final class Process {
465465

466466
try _process?.run()
467467
return stdinPipe.fileHandleForWriting
468-
#else
468+
#elseif (!canImport(Darwin) || os(macOS))
469469
// Initialize the spawn attributes.
470470
#if canImport(Darwin) || os(Android) || os(OpenBSD)
471471
var attributes: posix_spawnattr_t? = nil
@@ -481,7 +481,7 @@ public final class Process {
481481
posix_spawnattr_setsigmask(&attributes, &noSignals)
482482

483483
// Reset all signals to default behavior.
484-
#if os(macOS)
484+
#if canImport(Darwin)
485485
var mostSignals = sigset_t()
486486
sigfillset(&mostSignals)
487487
sigdelset(&mostSignals, SIGKILL)
@@ -521,7 +521,7 @@ public final class Process {
521521
defer { posix_spawn_file_actions_destroy(&fileActions) }
522522

523523
if let workingDirectory = workingDirectory?.pathString {
524-
#if os(macOS)
524+
#if canImport(Darwin)
525525
// The only way to set a workingDirectory is using an availability-gated initializer, so we don't need
526526
// to handle the case where the posix_spawn_file_actions_addchdir_np method is unavailable. This check only
527527
// exists here to make the compiler happy.
@@ -669,6 +669,8 @@ public final class Process {
669669
}
670670

671671
return stdinStream
672+
#else
673+
preconditionFailure("Process spawning is not available")
672674
#endif // POSIX implementation
673675
}
674676

@@ -849,7 +851,7 @@ extension Process: Hashable {
849851
// MARK: - Private helpers
850852

851853
#if !os(Windows)
852-
#if os(macOS)
854+
#if canImport(Darwin)
853855
private typealias swiftpm_posix_spawn_file_actions_t = posix_spawn_file_actions_t?
854856
#else
855857
private typealias swiftpm_posix_spawn_file_actions_t = posix_spawn_file_actions_t

Sources/TSCBasic/misc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public func exec(path: String, args: [String]) throws -> Never {
3333
else {
3434
throw SystemError.exec(errno, path: path, args: args)
3535
}
36-
#else
36+
#elseif (!canImport(Darwin) || os(macOS))
3737
guard execv(path, cArgs.cArray) != -1 else {
3838
throw SystemError.exec(errno, path: path, args: args)
3939
}

Sources/TSCTestSupport/FileSystemExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import func XCTest.XCTFail
1313
import TSCBasic
1414
import TSCUtility
1515

16-
#if os(macOS)
16+
#if canImport(Darwin)
1717
import class Foundation.Bundle
1818
#endif
1919

Sources/TSCTestSupport/Product.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import class Foundation.ProcessInfo
1414
import TSCBasic
1515
import TSCUtility
1616

17-
#if os(macOS)
17+
#if canImport(Darwin)
1818
import class Foundation.Bundle
1919
#endif
2020

@@ -33,7 +33,7 @@ public protocol Product {
3333
extension Product {
3434
/// Path to currently built binary.
3535
public var path: AbsolutePath {
36-
#if os(macOS)
36+
#if canImport(Darwin)
3737
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
3838
return AbsolutePath(bundle.bundlePath).parentDirectory.appending(self.exec)
3939
}

Sources/TSCTestSupport/XCTAssertHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import XCTest
1313
import TSCBasic
1414
import TSCUtility
1515

16-
#if os(macOS)
16+
#if canImport(Darwin)
1717
import class Foundation.Bundle
1818
#endif
1919

Sources/TSCTestSupport/XCTestCasePerf.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import TSCBasic
1818
/// This is useful because we always want to be able to compile the perf tests
1919
/// even if they are not run locally.
2020
open class XCTestCasePerf: XCTestCase {
21-
#if os(macOS)
21+
#if canImport(Darwin)
2222
override open class var defaultTestSuite: XCTestSuite {
2323
if ProcessEnv.vars.keys.contains("TSC_ENABLE_PERF_TESTS") {
2424
return super.defaultTestSuite

Sources/TSCTestSupport/misc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import class Foundation.Thread
1515
import TSCBasic
1616
import TSCUtility
1717

18-
#if os(macOS)
18+
#if canImport(Darwin)
1919
import class Foundation.Bundle
2020
#endif
2121

Sources/TSCUtility/FSWatch.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private protocol _FileWatcher {
100100
func stop()
101101
}
102102

103-
#if os(OpenBSD) || os(iOS)
103+
#if os(OpenBSD) || (!os(macOS) && canImport(Darwin))
104104
extension FSWatch._WatcherDelegate: NoOpWatcherDelegate {}
105105
extension NoOpWatcher: _FileWatcher{}
106106
#elseif os(Windows)
@@ -118,7 +118,7 @@ extension FSEventStream: _FileWatcher{}
118118

119119
// MARK:- inotify
120120

121-
#if os(OpenBSD) || os(iOS)
121+
#if os(OpenBSD) || (!os(macOS) && canImport(Darwin))
122122

123123
public protocol NoOpWatcherDelegate {
124124
func pathsDidReceiveEvent(_ paths: [AbsolutePath])

Sources/TSCUtility/Platform.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public enum Platform: Equatable {
8585
// Compute the directories.
8686
directories.append(AbsolutePath("/private/var/tmp"))
8787
(try? TSCBasic.determineTempDirectory()).map{ directories.append($0) }
88-
#if os(macOS)
88+
#if canImport(Darwin)
8989
getConfstr(_CS_DARWIN_USER_TEMP_DIR).map({ directories.append($0) })
9090
getConfstr(_CS_DARWIN_USER_CACHE_DIR).map({ directories.append($0) })
9191
#endif
@@ -95,7 +95,7 @@ public enum Platform: Equatable {
9595
}
9696

9797

98-
#if os(macOS)
98+
#if canImport(Darwin)
9999
/// Returns the value of given path variable using `getconf` utility.
100100
///
101101
/// - Note: This method returns `nil` if the value is an invalid path.

0 commit comments

Comments
 (0)