-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathPackage.swift
More file actions
164 lines (149 loc) · 4.71 KB
/
Copy pathPackage.swift
File metadata and controls
164 lines (149 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// swift-tools-version:6.0
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift System open source project
//
// Copyright (c) 2020 - 2026 Apple Inc. and the Swift System project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
import PackageDescription
struct Availability {
var name: String
var version: String
var osAvailability: String
var minSwiftPMVersions: String {
"macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, visionOS 1.0"
}
var minSpanDeploymentVersions: String {
"macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, visionOS 1.0"
}
var isStandardAvailability: Bool { name == "System" }
}
let availabilityMap: [(String, String)] = [
("0.0.1", "macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0"),
("0.0.2", "macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0"),
("1.1.0", "macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4"),
("1.2.0", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4"),
("1.4.0", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.0"),
("99", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
]
let availabilities: [Availability] =
availabilityMap.map {
Availability(name: "System", version: $0.0, osAvailability: $0.1)
} + availabilityMap.prefix(5).map {
Availability(name: "SystemWithSpan", version: $0.0, osAvailability: $0.1)
}
let swiftSettingsAvailability = availabilities.map {
availability -> SwiftSetting in
let osVersionList: String
#if SYSTEM_ABI_STABLE
// Use availability matching Darwin API.
osVersionList = availability.osAvailability
#else
if availability.isStandardAvailability {
// Use availability matching SwiftPM minimum.
osVersionList = availability.minSwiftPMVersions
} else {
// Use availability matching Span deployment minimum.
osVersionList = availability.minSpanDeploymentVersions
}
#endif
return .enableExperimentalFeature(
"AvailabilityMacro=\(availability.name) \(availability.version):\(osVersionList)"
)
}
#if SYSTEM_CI
let swiftSettingsCI: [SwiftSetting] = [
.unsafeFlags(["-require-explicit-availability=error"]),
]
#else
let swiftSettingsCI: [SwiftSetting] = []
#endif
let swiftSettings = swiftSettingsAvailability + swiftSettingsCI + [
.define(
"SYSTEM_PACKAGE_DARWIN",
.when(platforms: [.macOS, .macCatalyst, .iOS, .watchOS, .tvOS, .visionOS])),
.define("SYSTEM_PACKAGE"),
.define("ENABLE_MOCKING", .when(configuration: .debug)),
.enableExperimentalFeature("Lifetimes"),
]
let cSettings: [CSetting] = [
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])),
]
#if SYSTEM_ABI_STABLE
let platforms: [SupportedPlatform] = [
.macOS("26"),
.iOS("26"),
.watchOS("26"),
.tvOS("26"),
.visionOS("26"),
]
#else
let platforms: [SupportedPlatform]? = nil
#endif
#if os(Linux)
let filesToExclude = ["CMakeLists.txt"]
#else
let filesToExclude = ["CMakeLists.txt", "IORing"]
#endif
#if os(Linux)
let testsToExclude:[String] = []
#else
let testsToExclude = ["IORequestTests.swift", "IORingTests.swift"]
#endif
let package = Package(
name: "swift-system",
platforms: platforms,
products: [
.library(name: "SystemPackage", targets: ["SystemPackage"]),
.library(name: "SystemSockets", targets: ["SystemSockets"]),
.executable(name: "system-samples", targets: ["Samples"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
],
targets: [
.target(
name: "CSystem",
dependencies: [],
exclude: ["CMakeLists.txt"],
cSettings: cSettings),
.target(
name: "SystemPackage",
dependencies: ["CSystem"],
path: "Sources/System",
exclude: filesToExclude,
cSettings: cSettings,
swiftSettings: swiftSettings),
.testTarget(
name: "SystemTests",
dependencies: ["SystemPackage"],
exclude: testsToExclude,
cSettings: cSettings,
swiftSettings: swiftSettings),
.target(
name: "SystemSockets",
dependencies: ["SystemPackage", "CSystem"],
path: "Sources/SystemSockets",
cSettings: cSettings,
swiftSettings: swiftSettings),
.testTarget(
name: "SystemSocketsTests",
dependencies: ["SystemSockets"],
cSettings: cSettings,
swiftSettings: swiftSettings),
.executableTarget(
name: "Samples",
dependencies: [
"SystemPackage",
"SystemSockets",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
path: "Sources/Samples",
swiftSettings: swiftSettings),
],
swiftLanguageVersions: [.v5]
)