Clean up imports and dependencies. (#130)

Motivation:

With NIO 2.32.0 we broke the core NIO module up into modules that split
apart the POSIX layer and the core abstractions. As a result, this
package no longer needs to express a hard dependency on the POSIX layer.

Modifications:

- Rewrote imports of NIO to NIOCore.
- Added NIOEmbedded imports where necessary in tests.
- Note that the main package still _depends_ on NIO, which is necessary
  for backwards-compatibility reasons. This dependency is unused.

Result:

No need to use NIOPosix.
This commit is contained in:
Cory Benfield 2021-09-14 10:06:42 +01:00 committed by GitHub
parent 9571a61d23
commit e7f5278a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 66 additions and 53 deletions

View File

@ -28,6 +28,7 @@ let package = Package(
name: "NIOTransportServices",
dependencies: [
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOFoundationCompat", package: "swift-nio"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
.product(name: "NIOTLS", package: "swift-nio"),
@ -36,21 +37,22 @@ let package = Package(
name: "NIOTSHTTPClient",
dependencies: [
"NIOTransportServices",
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOHTTP1", package: "swift-nio"),
]),
.target(
name: "NIOTSHTTPServer",
dependencies: [
"NIOTransportServices",
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOHTTP1", package: "swift-nio"),
]),
.testTarget(
name: "NIOTransportServicesTests",
dependencies: [
"NIOTransportServices",
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOEmbedded", package: "swift-nio"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
]),
]

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#if canImport(Network)
import NIO
import NIOCore
import NIOTransportServices
import NIOHTTP1
import Network

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#if canImport(Network)
import NIO
import NIOCore
import NIOTransportServices
import NIOHTTP1
import Network

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2020 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2020-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
import NIO
import NIOCore
/// A `ChannelHandler` that checks for outbound writes of zero length, which are then dropped. This is

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2020 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2020-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#if canImport(Network)
import NIO
import NIOCore
/// Shared functionality across NIOTS bootstraps.
internal enum NIOTSBootstraps {

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
#if canImport(Network)
import NIO
import NIOCore
import Network
/// Options that can be set explicitly and only on bootstraps provided by `NIOTransportServices`.

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2020 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#if canImport(Network)
import NIO
import NIOCore
import Dispatch
import Network

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import Foundation
import NIO
import NIOCore
import NIOConcurrencyHelpers
import NIOFoundationCompat
import NIOTLS

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
#if canImport(Network)
import NIO
import NIOCore
/// A tag protocol that can be used to cover all errors thrown by `NIOTransportServices`.
///

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -17,7 +17,7 @@ import Dispatch
import Foundation
import Network
import NIO
import NIOCore
import NIOConcurrencyHelpers
/// An `EventLoop` that interacts with `DispatchQoS` to help schedule upcoming work.

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import Foundation
import NIO
import NIOCore
import NIOConcurrencyHelpers
import Dispatch
import Network

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2020 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#if canImport(Network)
import NIO
import NIOCore
import Dispatch
import Network

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import Foundation
import NIO
import NIOCore
import NIOFoundationCompat
import NIOConcurrencyHelpers
import Dispatch

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import Network
import NIO
import NIOCore
/// A tag protocol that can be used to cover all network events emitted by `NIOTS`.
///

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -15,7 +15,7 @@
#if canImport(Network)
import Darwin
import Foundation
import NIO
import NIOCore
import Network
@available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *)

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import Foundation
import NIO
import NIOCore
import NIOFoundationCompat
import NIOConcurrencyHelpers
import Dispatch

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import Foundation
import NIO
import NIOCore
import Network
@available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *)

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2020 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2020-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,8 @@
#if canImport(Network)
import XCTest
import NIO
import NIOCore
import NIOEmbedded
import NIOTransportServices

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2019 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2019-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -15,7 +15,8 @@
#if canImport(Network)
import XCTest
import Network
import NIO
import NIOCore
import NIOEmbedded
import NIOTransportServices
import NIOConcurrencyHelpers
import Foundation

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2020 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2020-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import XCTest
import NIO
import NIOCore
import NIOConcurrencyHelpers
import NIOTransportServices
import Network

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -15,7 +15,7 @@
#if canImport(Network)
import XCTest
import Network
import NIO
import NIOCore
import NIOTransportServices
import Foundation

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import XCTest
import NIO
import NIOCore
import NIOTransportServices
import Foundation
import Network

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import XCTest
import NIO
import NIOCore
import NIOConcurrencyHelpers
import NIOTransportServices

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -15,7 +15,7 @@
#if canImport(Network)
import XCTest
import Network
import NIO
import NIOCore
import NIOTransportServices

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import XCTest
import NIO
import NIOCore
import Network
@testable import NIOTransportServices

View File

@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
@ -14,7 +14,7 @@
#if canImport(Network)
import XCTest
import NIO
import NIOCore
import Network
@testable import NIOTransportServices

View File

@ -21,6 +21,15 @@ function replace_acceptable_years() {
sed -e 's/20[12][78901]-20[12][8901]/YEARS/' -e 's/20[12][8901]/YEARS/'
}
# This checks for the umbrella NIO module.
printf "=> Checking for imports of umbrella NIO module... "
if git grep --color=never -i "^[ \t]*import \+NIO[ \t]*$" > /dev/null; then
printf "\033[0;31mUmbrella imports found.\033[0m\n"
git grep -i "^[ \t]*import \+NIO[ \t]*$"
exit 1
fi
printf "\033[0;32mokay.\033[0m\n"
printf "=> Checking license headers... "
tmp=$(mktemp /tmp/.swift-nio-sanity_XXXXXX)