make NIOTS compile on Linux (#29)
Motivation: NIOTS will not work on Linux but we can at least make it not fail compilation when compiled on Linux. That way consumers of the API can depend on NIOTS but make sure they only use NIOTS when wrapped in a `#if canImport(Network)` block. Modification: Guard everything by `#if canImport(Network)` Result: This package will now build on Linux (without providing any useful code).
This commit is contained in:
parent
501197f000
commit
d68f9d1f8e
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import NIO
|
||||
import NIOTransportServices
|
||||
import NIOHTTP1
|
||||
|
|
@ -69,3 +71,4 @@ let channel = try! NIOTSConnectionBootstrap(group: group)
|
|||
|
||||
// Wait for the request to complete
|
||||
try! channel.closeFuture.wait()
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import NIO
|
||||
import NIOTransportServices
|
||||
import NIOHTTP1
|
||||
|
|
@ -48,3 +50,4 @@ print("Server listening on \(channel.localAddress!)")
|
|||
|
||||
// Wait for the request to complete
|
||||
try! channel.closeFuture.wait()
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,11 +13,12 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import NIO
|
||||
import Dispatch
|
||||
import Network
|
||||
|
||||
|
||||
public final class NIOTSConnectionBootstrap {
|
||||
private let group: NIOTSEventLoopGroup
|
||||
private var channelInitializer: ((Channel) -> EventLoopFuture<Void>)?
|
||||
|
|
@ -219,3 +220,4 @@ internal struct ChannelOptionStorage {
|
|||
return applyPromise.futureResult
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import Foundation
|
||||
import NIO
|
||||
import NIOConcurrencyHelpers
|
||||
|
|
@ -807,3 +809,4 @@ fileprivate extension ChannelState where ActiveSubstate == NIOTSConnectionChanne
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import Dispatch
|
||||
import Foundation
|
||||
import Network
|
||||
|
|
@ -220,3 +221,4 @@ extension NIOTSEventLoop {
|
|||
assert(oldChannel != nil)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import Foundation
|
||||
import NIO
|
||||
import NIOConcurrencyHelpers
|
||||
|
|
@ -82,3 +84,4 @@ public final class NIOTSEventLoopGroup: EventLoopGroup {
|
|||
return EventLoopIterator(self.eventLoops)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import NIO
|
||||
import Dispatch
|
||||
import Network
|
||||
|
|
@ -308,3 +310,4 @@ private class AcceptHandler: ChannelInboundHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import Foundation
|
||||
import NIO
|
||||
import NIOFoundationCompat
|
||||
|
|
@ -421,3 +423,4 @@ extension NIOTSListenerChannel {
|
|||
self.becomeActive0(promise: promise)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import Network
|
||||
import NIO
|
||||
|
||||
|
|
@ -66,3 +68,4 @@ public enum NIOTSNetworkEvents {
|
|||
public let endpoint: NWEndpoint
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import Darwin
|
||||
import Foundation
|
||||
import NIO
|
||||
|
|
@ -121,3 +123,4 @@ internal extension SocketAddress {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import Foundation
|
||||
import NIO
|
||||
import NIOFoundationCompat
|
||||
|
|
@ -266,3 +268,4 @@ extension StateManagedChannel {
|
|||
self.beginActivating0(to: endpoint, promise: promise)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import Foundation
|
||||
import NIO
|
||||
import Network
|
||||
|
|
@ -82,3 +84,4 @@ internal extension NWProtocolTCP.Options {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import XCTest
|
||||
import Network
|
||||
import NIO
|
||||
|
|
@ -638,3 +640,4 @@ class NIOTSConnectionChannelTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import XCTest
|
||||
import NIO
|
||||
import NIOTransportServices
|
||||
|
|
@ -491,3 +493,4 @@ class NIOTSEndToEndTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import XCTest
|
||||
import NIO
|
||||
import NIOConcurrencyHelpers
|
||||
|
|
@ -127,3 +129,4 @@ class NIOTSEventLoopTest: XCTestCase {
|
|||
XCTAssertNil(weakEL)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import XCTest
|
||||
import Network
|
||||
import NIO
|
||||
|
|
@ -219,3 +221,4 @@ class NIOTSListenerChannelTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import XCTest
|
||||
import NIO
|
||||
import Network
|
||||
|
|
@ -162,3 +164,4 @@ class NIOTSSocketOptionTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if canImport(Network)
|
||||
import XCTest
|
||||
import NIO
|
||||
import Network
|
||||
|
|
@ -121,4 +123,4 @@ class NIOTSSocketOptionsOnChannelTests: XCTestCase {
|
|||
try self.assertChannelOptionAfterCreation(option: SocketOption(level: SOL_SOCKET, name: SO_KEEPALIVE), initialValue: 0, testAlternativeValue: 1)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue