Skip to content

Commit 81b58e0

Browse files
committed
Handle system package better
1 parent 6005fac commit 81b58e0

File tree

10 files changed

+70
-40
lines changed

10 files changed

+70
-40
lines changed

Package.resolved

Lines changed: 6 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,34 @@ import PackageDescription
55
let package = Package(
66
name: "swift-signal-handling",
77
platforms: [
8-
.macOS(.v10_15)
8+
.macOS(.v11),
9+
.tvOS(.v14),
10+
.iOS(.v14),
11+
.watchOS(.v7)
912
],
1013
products: [
1114
.library(name: "SignalHandling", targets: ["SignalHandling"])
1215
],
13-
dependencies: [
14-
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.0"),
15-
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.2"),
16-
.package(url: "https://github.com/apple/swift-system.git", from: "1.0.0"),
17-
.package(url: "https://github.com/swift-server/swift-backtrace.git", from: "1.3.1"),
18-
.package(url: "https://github.com/xcode-actions/clt-logger.git", from: "0.3.0")
19-
],
16+
dependencies: {
17+
var res = [Package.Dependency]()
18+
res.append(.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.0"))
19+
res.append(.package(url: "https://github.com/apple/swift-log.git", from: "1.4.2"))
20+
res.append(.package(url: "https://github.com/swift-server/swift-backtrace.git", from: "1.3.1"))
21+
res.append(.package(url: "https://github.com/xcode-actions/clt-logger.git", from: "0.4.0"))
22+
#if !canImport(System)
23+
res.append(.package(url: "https://github.com/apple/swift-system.git", from: "1.0.0"))
24+
#endif
25+
return res
26+
}(),
2027
targets: [
21-
.target(name: "SignalHandling", dependencies: [
22-
.product(name: "Logging", package: "swift-log"),
23-
.product(name: "SystemPackage", package: "swift-system")
24-
]),
28+
.target(name: "SignalHandling", dependencies: {
29+
var res = [Target.Dependency]()
30+
res.append(.product(name: "Logging", package: "swift-log"))
31+
#if !canImport(System)
32+
res.append(.product(name: "SystemPackage", package: "swift-system"))
33+
#endif
34+
return res
35+
}()),
2536

2637
.target(name: "signal-handling-tests-helper", dependencies: [
2738
.product(name: "ArgumentParser", package: "swift-argument-parser"),
@@ -30,11 +41,15 @@ let package = Package(
3041
.product(name: "Logging", package: "swift-log"),
3142
.target(name: "SignalHandling")
3243
]),
33-
.testTarget(name: "SignalHandlingTests", dependencies: [
34-
.target(name: "signal-handling-tests-helper"),
35-
.product(name: "CLTLogger", package: "clt-logger"),
36-
.product(name: "Logging", package: "swift-log"),
37-
.product(name: "SystemPackage", package: "swift-system")
38-
]),
44+
.testTarget(name: "SignalHandlingTests", dependencies: {
45+
var res = [Target.Dependency]()
46+
res.append(.target(name: "signal-handling-tests-helper"))
47+
res.append(.product(name: "CLTLogger", package: "clt-logger"))
48+
res.append(.product(name: "Logging", package: "swift-log"))
49+
#if !canImport(System)
50+
res.append(.product(name: "SystemPackage", package: "swift-system"))
51+
#endif
52+
return res
53+
}())
3954
]
4055
)

Sources/SignalHandling/CStructsInSwift/Sigaction.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import Foundation
2-
2+
#if canImport(System)
3+
import System
4+
#else
35
import SystemPackage
6+
#endif
47

58

69

Sources/SignalHandling/DelayedSigaction/SigactionDelayer_Block.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import Foundation
2-
2+
#if canImport(System)
3+
import System
4+
#else
35
import SystemPackage
6+
#endif
47

58

69

Sources/SignalHandling/DelayedSigaction/SigactionDelayer_Unsig.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import Foundation
2+
#if canImport(System)
3+
import System
4+
#else
5+
import SystemPackage
6+
#endif
27

38
import Logging
4-
import SystemPackage
59

610

711

Sources/SignalHandling/SignalHandlingError.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import Foundation
2-
2+
#if canImport(System)
3+
import System
4+
#else
35
import SystemPackage
6+
#endif
47

58

69

Sources/signal-handling-tests-helper/DelaySignalBlock.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import Foundation
2+
#if canImport(System)
3+
import System
4+
#else
5+
import SystemPackage
6+
#endif
27

38
import ArgumentParser
49
import CLTLogger
510
import Logging
6-
import SystemPackage
711

812
import SignalHandling
913

Sources/signal-handling-tests-helper/DelaySignalUnsigaction.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import Foundation
2+
#if canImport(System)
3+
import System
4+
#else
5+
import SystemPackage
6+
#endif
27

38
import ArgumentParser
49
import CLTLogger
510
import Logging
6-
import SystemPackage
711

812
import SignalHandling
913

Tests/SignalHandlingTests/LockTest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import XCTest
33

44

55

6+
#if !os(tvOS) && !os(iOS) && !os(watchOS)
67
final class NSConditionLockTest : XCTestCase {
78

89
func testNSConditionLock() throws {
@@ -26,3 +27,4 @@ final class NSConditionLockTest : XCTestCase {
2627
}
2728

2829
}
30+
#endif

Tests/SignalHandlingTests/SignalHandlingTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Logging
88

99

1010

11-
@available(OSX 10.15.4, *)
11+
#if !os(tvOS) && !os(iOS) && !os(watchOS)
1212
final class SignalHandlingTests : XCTestCase {
1313

1414
override class func setUp() {
@@ -73,3 +73,4 @@ final class SignalHandlingTests : XCTestCase {
7373
}
7474

7575
}
76+
#endif

0 commit comments

Comments
 (0)