Skip to content

Commit f0e80d1

Browse files
[Wrangle] Revert noasync annotation. (#392)
* Revert "Require a 5.8 compiler to conditionally compile the noasync attribute" This reverts commit a73a7aa. * Revert "Add some noasync annotations and async overloads for improved Swift Concurrency interop" This reverts commit 3d2497e.
1 parent a73a7aa commit f0e80d1

File tree

5 files changed

+6
-243
lines changed

5 files changed

+6
-243
lines changed

Sources/TSCBasic/Await.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@
1414
/// should be passed to the async method's completion handler.
1515
/// - Returns: The value wrapped by the async method's result.
1616
/// - Throws: The error wrapped by the async method's result
17-
#if compiler(>=5.8)
18-
@available(*, noasync)
19-
#endif
2017
public func tsc_await<T, ErrorType>(_ body: (@escaping (Result<T, ErrorType>) -> Void) -> Void) throws -> T {
2118
return try tsc_await(body).get()
2219
}
2320

24-
#if compiler(>=5.8)
25-
@available(*, noasync)
26-
#endif
2721
public func tsc_await<T>(_ body: (@escaping (T) -> Void) -> Void) -> T {
2822
let condition = Condition()
2923
var result: T? = nil

Sources/TSCBasic/Process.swift

Lines changed: 4 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,18 @@ import Foundation
2121
import TSCLibc
2222
import Dispatch
2323

24-
import _Concurrency
25-
2624
/// Process result data which is available after process termination.
27-
public struct ProcessResult: CustomStringConvertible, Sendable {
25+
public struct ProcessResult: CustomStringConvertible {
2826

29-
public enum Error: Swift.Error, Sendable {
27+
public enum Error: Swift.Error {
3028
/// The output is not a valid UTF8 sequence.
3129
case illegalUTF8Sequence
3230

3331
/// The process had a non zero exit.
3432
case nonZeroExit(ProcessResult)
3533
}
3634

37-
public enum ExitStatus: Equatable, Sendable {
35+
public enum ExitStatus: Equatable {
3836
/// The process was terminated normally with a exit code.
3937
case terminated(code: Int32)
4038
#if os(Windows)
@@ -127,18 +125,12 @@ public struct ProcessResult: CustomStringConvertible, Sendable {
127125
}
128126
}
129127

130-
#if swift(<5.6)
131-
extension Process: UnsafeSendable {}
132-
#else
133-
extension Process: @unchecked Sendable {}
134-
#endif
135-
136128
/// Process allows spawning new subprocesses and working with them.
137129
///
138130
/// Note: This class is thread safe.
139131
public final class Process {
140132
/// Errors when attempting to invoke a process
141-
public enum Error: Swift.Error, Sendable {
133+
public enum Error: Swift.Error {
142134
/// The program requested to be executed cannot be found on the existing search paths, or is not executable.
143135
case missingExecutableProgram(program: String)
144136

@@ -815,29 +807,7 @@ public final class Process {
815807
#endif // POSIX implementation
816808
}
817809

818-
/// Executes the process I/O state machine, returning the result when finished.
819-
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
820-
@discardableResult
821-
public func waitUntilExit() async throws -> ProcessResult {
822-
#if compiler(>=5.6)
823-
return try await withCheckedThrowingContinuation { continuation in
824-
waitUntilExit(continuation.resume(with:))
825-
}
826-
#else
827-
if #available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *) {
828-
return try await withCheckedThrowingContinuation { continuation in
829-
waitUntilExit(continuation.resume(with:))
830-
}
831-
} else {
832-
preconditionFailure("Unsupported with Swift 5.5 on this OS version")
833-
}
834-
#endif
835-
}
836-
837810
/// Blocks the calling process until the subprocess finishes execution.
838-
#if compiler(>=5.8)
839-
@available(*, noasync)
840-
#endif
841811
@discardableResult
842812
public func waitUntilExit() throws -> ProcessResult {
843813
let group = DispatchGroup()
@@ -968,88 +938,6 @@ public final class Process {
968938
}
969939
}
970940

971-
extension Process {
972-
/// Execute a subprocess and returns the result when it finishes execution
973-
///
974-
/// - Parameters:
975-
/// - arguments: The arguments for the subprocess.
976-
/// - environment: The environment to pass to subprocess. By default the current process environment
977-
/// will be inherited.
978-
/// - loggingHandler: Handler for logging messages
979-
@available(macOS 10.15, *)
980-
static public func popen(
981-
arguments: [String],
982-
environment: [String: String] = ProcessEnv.vars,
983-
loggingHandler: LoggingHandler? = .none
984-
) async throws -> ProcessResult {
985-
let process = Process(
986-
arguments: arguments,
987-
environment: environment,
988-
outputRedirection: .collect,
989-
loggingHandler: loggingHandler
990-
)
991-
try process.launch()
992-
return try await process.waitUntilExit()
993-
}
994-
995-
/// Execute a subprocess and returns the result when it finishes execution
996-
///
997-
/// - Parameters:
998-
/// - args: The arguments for the subprocess.
999-
/// - environment: The environment to pass to subprocess. By default the current process environment
1000-
/// will be inherited.
1001-
/// - loggingHandler: Handler for logging messages
1002-
@available(macOS 10.15, *)
1003-
static public func popen(
1004-
args: String...,
1005-
environment: [String: String] = ProcessEnv.vars,
1006-
loggingHandler: LoggingHandler? = .none
1007-
) async throws -> ProcessResult {
1008-
try await popen(arguments: args, environment: environment, loggingHandler: loggingHandler)
1009-
}
1010-
1011-
/// Execute a subprocess and get its (UTF-8) output if it has a non zero exit.
1012-
///
1013-
/// - Parameters:
1014-
/// - arguments: The arguments for the subprocess.
1015-
/// - environment: The environment to pass to subprocess. By default the current process environment
1016-
/// will be inherited.
1017-
/// - loggingHandler: Handler for logging messages
1018-
/// - Returns: The process output (stdout + stderr).
1019-
@available(macOS 10.15, *)
1020-
@discardableResult
1021-
static public func checkNonZeroExit(
1022-
arguments: [String],
1023-
environment: [String: String] = ProcessEnv.vars,
1024-
loggingHandler: LoggingHandler? = .none
1025-
) async throws -> String {
1026-
let result = try await popen(arguments: arguments, environment: environment, loggingHandler: loggingHandler)
1027-
// Throw if there was a non zero termination.
1028-
guard result.exitStatus == .terminated(code: 0) else {
1029-
throw ProcessResult.Error.nonZeroExit(result)
1030-
}
1031-
return try result.utf8Output()
1032-
}
1033-
1034-
/// Execute a subprocess and get its (UTF-8) output if it has a non zero exit.
1035-
///
1036-
/// - Parameters:
1037-
/// - args: The arguments for the subprocess.
1038-
/// - environment: The environment to pass to subprocess. By default the current process environment
1039-
/// will be inherited.
1040-
/// - loggingHandler: Handler for logging messages
1041-
/// - Returns: The process output (stdout + stderr).
1042-
@available(macOS 10.15, *)
1043-
@discardableResult
1044-
static public func checkNonZeroExit(
1045-
args: String...,
1046-
environment: [String: String] = ProcessEnv.vars,
1047-
loggingHandler: LoggingHandler? = .none
1048-
) async throws -> String {
1049-
try await checkNonZeroExit(arguments: args, environment: environment, loggingHandler: loggingHandler)
1050-
}
1051-
}
1052-
1053941
extension Process {
1054942
/// Execute a subprocess and calls completion block when it finishes execution
1055943
///
@@ -1060,9 +948,6 @@ extension Process {
1060948
/// - loggingHandler: Handler for logging messages
1061949
/// - queue: Queue to use for callbacks
1062950
/// - completion: A completion handler to return the process result
1063-
#if compiler(>=5.8)
1064-
@available(*, noasync)
1065-
#endif
1066951
static public func popen(
1067952
arguments: [String],
1068953
environment: [String: String] = ProcessEnv.vars,
@@ -1097,9 +982,6 @@ extension Process {
1097982
/// will be inherited.
1098983
/// - loggingHandler: Handler for logging messages
1099984
/// - Returns: The process result.
1100-
#if compiler(>=5.8)
1101-
@available(*, noasync)
1102-
#endif
1103985
@discardableResult
1104986
static public func popen(
1105987
arguments: [String],
@@ -1124,9 +1006,6 @@ extension Process {
11241006
/// will be inherited.
11251007
/// - loggingHandler: Handler for logging messages
11261008
/// - Returns: The process result.
1127-
#if compiler(>=5.8)
1128-
@available(*, noasync)
1129-
#endif
11301009
@discardableResult
11311010
static public func popen(
11321011
args: String...,
@@ -1144,9 +1023,6 @@ extension Process {
11441023
/// will be inherited.
11451024
/// - loggingHandler: Handler for logging messages
11461025
/// - Returns: The process output (stdout + stderr).
1147-
#if compiler(>=5.8)
1148-
@available(*, noasync)
1149-
#endif
11501026
@discardableResult
11511027
static public func checkNonZeroExit(
11521028
arguments: [String],
@@ -1176,9 +1052,6 @@ extension Process {
11761052
/// will be inherited.
11771053
/// - loggingHandler: Handler for logging messages
11781054
/// - Returns: The process output (stdout + stderr).
1179-
#if compiler(>=5.8)
1180-
@available(*, noasync)
1181-
#endif
11821055
@discardableResult
11831056
static public func checkNonZeroExit(
11841057
args: String...,

Sources/TSCBasic/ProcessSet.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ public final class ProcessSet {
6464
/// Terminate all the processes. This method blocks until all processes in the set are terminated.
6565
///
6666
/// A process set cannot be used once it has been asked to terminate.
67-
#if compiler(>=5.8)
68-
@available(*, noasync)
69-
#endif
7067
public func terminate() {
7168
// Mark a process set as cancelled.
7269
serialQueue.sync {

Sources/TSCBasic/WritableByteStream.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public final class ThreadSafeOutputByteStream: WritableByteStream {
349349
}
350350

351351

352-
#if swift(<5.6)
352+
#if swift(<5.7)
353353
extension ThreadSafeOutputByteStream: UnsafeSendable {}
354354
#else
355355
extension ThreadSafeOutputByteStream: @unchecked Sendable {}

0 commit comments

Comments
 (0)