Skip to content

Commit

Permalink
Issue-2900 - Add VisionOS support (#2947)
Browse files Browse the repository at this point in the history
Add Vision support

### Motivation:
#2900 - close this

### Modifications:
- Bump SystemPackage to 1.4.0 and remove @preconcurrency 
- remove `#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) ||
os(Linux) || os(Android)` to allow for visionOS support
- Remove conditional import for swift system

### Result:

Vision OS support
  • Loading branch information
ali-ahsan-ali authored Oct 24, 2024
1 parent 062b28e commit 9140817
Show file tree
Hide file tree
Showing 55 changed files with 30 additions and 169 deletions.
8 changes: 2 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ import class Foundation.ProcessInfo

let swiftAtomics: PackageDescription.Target.Dependency = .product(name: "Atomics", package: "swift-atomics")
let swiftCollections: PackageDescription.Target.Dependency = .product(name: "DequeModule", package: "swift-collections")
let swiftSystem: PackageDescription.Target.Dependency = .product(
name: "SystemPackage",
package: "swift-system",
condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .linux, .android])
)
let swiftSystem: PackageDescription.Target.Dependency = .product(name: "SystemPackage", package: "swift-system")

// These platforms require a depdency on `NIOPosix` from `NIOHTTP1` to maintain backward
// compatibility with previous NIO versions.
Expand Down Expand Up @@ -558,7 +554,7 @@ if Context.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
package.dependencies += [
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.1.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.2"),
.package(url: "https://github.com/apple/swift-system.git", from: "1.2.0"),
.package(url: "https://github.com/apple/swift-system.git", from: "1.4.0"),
]
} else {
package.dependencies += [
Expand Down
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/BufferedReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import DequeModule
import NIOCore

Expand Down Expand Up @@ -240,5 +239,3 @@ extension ReadableFileHandleProtocol {
BufferedReader(wrapping: self, initialOffset: initialOffset, capacity: Int(capacity.bytes))
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/BufferedWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import NIOCore

/// A writer which buffers bytes in memory before writing them to the file system.
Expand Down Expand Up @@ -244,5 +243,3 @@ extension WritableFileHandleProtocol {
}
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/ByteBuffer+FileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import NIOCore

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
Expand Down Expand Up @@ -96,5 +95,3 @@ extension ByteBuffer {
)
}
}

#endif
4 changes: 0 additions & 4 deletions Sources/NIOFileSystem/ByteCount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)

/// Represents the number of bytes.
public struct ByteCount: Hashable, Sendable {
/// The number of bytes
Expand Down Expand Up @@ -117,5 +115,3 @@ extension ByteCount: Comparable {
lhs.bytes < rhs.bytes
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import SystemPackage

extension String {
Expand Down Expand Up @@ -201,5 +200,3 @@ extension AsyncSequence where Self.Element == UInt8, Self: Sendable {
)
}
}

#endif
5 changes: 1 addition & 4 deletions Sources/NIOFileSystem/DirectoryEntries.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import CNIODarwin
import CNIOLinux
import NIOConcurrencyHelpers
import NIOCore
import NIOPosix
@preconcurrency import SystemPackage
import SystemPackage

/// An `AsyncSequence` of entries in a directory.
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
Expand Down Expand Up @@ -737,5 +736,3 @@ extension UnsafeMutablePointer<CInterop.FTSEnt> {
FilePath(platformString: self.pointee.fts_path!)
}
}

#endif
5 changes: 1 addition & 4 deletions Sources/NIOFileSystem/DirectoryEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
@preconcurrency import SystemPackage
import SystemPackage

/// Information about an item within a directory.
public struct DirectoryEntry: Sendable, Hashable, Equatable {
Expand Down Expand Up @@ -46,5 +45,3 @@ public struct DirectoryEntry: Sendable, Hashable, Equatable {
self.type = type
}
}

#endif
4 changes: 0 additions & 4 deletions Sources/NIOFileSystem/Exports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)

// These types are used in our public API; expose them to make
// life easier for users.
@_exported import enum SystemPackage.CInterop
@_exported import struct SystemPackage.Errno
@_exported import struct SystemPackage.FileDescriptor
@_exported import struct SystemPackage.FilePath
@_exported import struct SystemPackage.FilePermissions

#endif
4 changes: 1 addition & 3 deletions Sources/NIOFileSystem/FileChunks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import NIOConcurrencyHelpers
import NIOCore
import NIOPosix
@preconcurrency import SystemPackage
import SystemPackage

/// An `AsyncSequence` of ordered chunks read from a file.
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
Expand Down Expand Up @@ -544,4 +543,3 @@ extension ProducerState.Producing {
return .moreToRead
}
}
#endif
4 changes: 0 additions & 4 deletions Sources/NIOFileSystem/FileHandle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)

import NIOCore

/// Provides a ``FileHandle``.
Expand Down Expand Up @@ -357,5 +355,3 @@ public struct DirectoryFileHandle: DirectoryFileHandleProtocol, _HasFileHandle {
return DirectoryFileHandle(wrapping: systemFileHandle)
}
}

#endif
2 changes: 0 additions & 2 deletions Sources/NIOFileSystem/FileHandleProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import NIOCore
import SystemPackage

Expand Down Expand Up @@ -775,4 +774,3 @@ extension DirectoryFileHandleProtocol {
}
}
}
#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/FileInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import SystemPackage

#if canImport(Darwin)
Expand Down Expand Up @@ -277,5 +276,3 @@ extension FilePermissions {
self = .init(rawValue: rawValue & ~S_IFMT)
}
}

#endif
5 changes: 1 addition & 4 deletions Sources/NIOFileSystem/FileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)

import Atomics
import NIOCore
import NIOPosix
@preconcurrency import SystemPackage
import SystemPackage

#if canImport(Darwin)
import Darwin
Expand Down Expand Up @@ -1539,4 +1537,3 @@ extension FileSystem {
}
}
}
#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/FileSystemError+Syscall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import SystemPackage

#if canImport(Darwin)
Expand Down Expand Up @@ -1157,5 +1156,3 @@ extension FileSystemError {
)
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/FileSystemError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import SystemPackage

/// An error thrown as a result of interaction with the file system.
Expand Down Expand Up @@ -279,5 +278,3 @@ extension FileSystemError {
}
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/FileSystemProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import SystemPackage

/// The interface for interacting with a file system.
Expand Down Expand Up @@ -663,5 +662,3 @@ extension FileSystemProtocol {
}
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/FileType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import SystemPackage

#if canImport(Darwin)
Expand Down Expand Up @@ -170,5 +169,3 @@ extension FileType {
}
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/Internal/BufferedOrAnyStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import NIOCore

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
/// Wraps a ``NIOThrowingAsyncSequenceProducer<Element>`` or ``AnyAsyncSequence<Element>``.
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
internal enum BufferedOrAnyStream<Element, Delegate: NIOAsyncSequenceProducerDelegate> {
Expand Down Expand Up @@ -95,5 +94,3 @@ internal struct AnyAsyncSequence<Element>: AsyncSequence {
}
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/NIOFileSystem/Internal/BufferedStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import DequeModule
import NIOConcurrencyHelpers

Expand Down Expand Up @@ -1732,5 +1731,3 @@ extension BufferedStream {
}
}
}

#endif
4 changes: 0 additions & 4 deletions Sources/NIOFileSystem/Internal/Cancellation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)

/// Executes the closure and masks cancellation.
@_spi(Testing)
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
Expand Down Expand Up @@ -54,5 +52,3 @@ public func withUncancellableTearDown<R>(
try tearDownResult.get()
return try result.get()
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
@usableFromInline
struct UnsafeTransfer<Value>: @unchecked Sendable {
@usableFromInline
Expand All @@ -23,4 +22,3 @@ struct UnsafeTransfer<Value>: @unchecked Sendable {
self.wrappedValue = wrappedValue
}
}
#endif
2 changes: 0 additions & 2 deletions Sources/NIOFileSystem/Internal/ParallelDirCopy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import NIOCore

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
Expand Down Expand Up @@ -161,4 +160,3 @@ private struct DirCopyDelegate: NIOAsyncSequenceProducerDelegate, Sendable {
@inlinable
func didTerminate() {}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)

extension String {
@inlinable
init(
Expand Down Expand Up @@ -61,5 +59,3 @@ extension String {
}
}
}

#endif
2 changes: 0 additions & 2 deletions Sources/NIOFileSystem/Internal/System Calls/CInterop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import SystemPackage

#if canImport(Darwin)
Expand Down Expand Up @@ -82,4 +81,3 @@ extension CInterop {
typealias FTSPointer = UnsafeMutablePointer<FTS>
typealias FTSEntPointer = UnsafeMutablePointer<CInterop.FTSEnt>
}
#endif
2 changes: 0 additions & 2 deletions Sources/NIOFileSystem/Internal/System Calls/Errno.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
import SystemPackage

#if canImport(Darwin)
Expand Down Expand Up @@ -147,4 +146,3 @@ public func valueOrErrno<R>(
}
}
}
#endif
Loading

0 comments on commit 9140817

Please sign in to comment.