Skip to content

Commit

Permalink
Merge pull request #41 from MaxDesiatov/maxd/fix-wasi-builds
Browse files Browse the repository at this point in the history
Fix package not building for WASI
  • Loading branch information
guoye-zhang committed Jan 12, 2024
2 parents 1827dc9 + a114507 commit 782b1bf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/HTTPTypes/HTTPFields.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

#if canImport(os.lock)
import os.lock
#else
#elseif canImport(Glibc)
import Glibc
#elseif canImport(WASILibc)
import WASILibc
#endif

/// A collection of HTTP fields. It is used in `HTTPRequest` and `HTTPResponse`, and can also be
Expand Down
4 changes: 4 additions & 0 deletions Sources/HTTPTypesFoundation/URLRequest+HTTPTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import HTTPTypes
import FoundationNetworking
#endif

#if !os(WASI)

extension URLRequest {
/// Create a `URLRequest` from an `HTTPRequest`.
/// - Parameter httpRequest: The HTTP request to convert from.
Expand Down Expand Up @@ -63,3 +65,5 @@ extension URLRequest {
return request
}
}

#endif
4 changes: 4 additions & 0 deletions Sources/HTTPTypesFoundation/URLResponse+HTTPTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import HTTPTypes
import FoundationNetworking
#endif

#if !os(WASI)

extension HTTPURLResponse {
/// Create an `HTTPURLResponse` from an `HTTPResponse`.
/// - Parameter httpResponse: The HTTP response to convert from.
Expand Down Expand Up @@ -55,3 +57,5 @@ extension HTTPURLResponse {
return response
}
}

#endif
4 changes: 4 additions & 0 deletions Sources/HTTPTypesFoundation/URLSession+HTTPTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import HTTPTypes
import FoundationNetworking
#endif

#if !os(WASI)

extension URLSessionTask {
/// The original HTTP request this task was created with.
public var originalHTTPRequest: HTTPRequest? {
Expand All @@ -40,6 +42,8 @@ private enum HTTPTypeConversionError: Error {
case failedToConvertURLResponseToHTTPResponse
}

#endif

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
Expand Down

0 comments on commit 782b1bf

Please sign in to comment.