Skip to content

Add Swift wrapper functions for C API to avoid clients needing to depend on the importer #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Sources/TSCBasic/Process/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1316,10 +1316,10 @@ extension Process: Hashable {
// MARK: - Private helpers

#if !os(Windows)
#if canImport(Darwin)
private typealias swiftpm_posix_spawn_file_actions_t = posix_spawn_file_actions_t?
#if canImport(Darwin) || os(FreeBSD) || os(OpenBSD)
public typealias swiftpm_posix_spawn_file_actions_t = posix_spawn_file_actions_t?
#else
private typealias swiftpm_posix_spawn_file_actions_t = posix_spawn_file_actions_t
public typealias swiftpm_posix_spawn_file_actions_t = posix_spawn_file_actions_t
#endif

private func WIFEXITED(_ status: Int32) -> Bool {
Expand Down Expand Up @@ -1455,3 +1455,17 @@ extension Process {
stdoutStream.flush()
}
}

#if !os(Windows)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(visionOS, unavailable)
public func TSC_posix_spawn_file_actions_addchdir_np(_ file_actions: UnsafeMutablePointer<swiftpm_posix_spawn_file_actions_t>?, _ path: UnsafePointer<CChar>?) -> CInt {
TSCclibc.SPM_posix_spawn_file_actions_addchdir_np(file_actions, path)
}

public func TSC_posix_spawn_file_actions_addchdir_np_supported() -> Bool {
TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported()
}
#endif