Skip to content

Commit a51b9ef

Browse files
committed
AsyncProcess: simplify the code path to not depend on the TSC wrappers functions on Darwin
1 parent d1ab457 commit a51b9ef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/Basics/Concurrency/AsyncProcess.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import TSCLibc
1818
import Android
1919
#endif
2020

21-
#if !os(Windows)
21+
#if !os(Windows) && !canImport(Darwin)
2222
#if USE_IMPL_ONLY_IMPORTS
2323
@_implementationOnly
2424
import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported
@@ -29,7 +29,7 @@ import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np
2929
private import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported
3030
private import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np
3131
#endif // #if USE_IMPL_ONLY_IMPORTS
32-
#endif // #if os(Linux)
32+
#endif
3333

3434
import class TSCBasic.CStringArray
3535
import class TSCBasic.LocalFileOutputByteStream
@@ -621,11 +621,15 @@ package final class AsyncProcess {
621621
defer { posix_spawn_file_actions_destroy(&fileActions) }
622622

623623
if let workingDirectory = workingDirectory?.pathString {
624+
#if canImport(Darwin)
625+
posix_spawn_file_actions_addchdir_np(&fileActions, workingDirectory)
626+
#else
624627
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
625628
throw AsyncProcess.Error.workingDirectoryNotSupported
626629
}
627630

628631
SPM_posix_spawn_file_actions_addchdir_np(&fileActions, workingDirectory)
632+
#endif
629633
}
630634

631635
var stdinPipe: [Int32] = [-1, -1]

0 commit comments

Comments
 (0)