-
Notifications
You must be signed in to change notification settings - Fork 598
Expand file tree
/
Copy pathPackage@swift-6.2.swift
More file actions
189 lines (182 loc) · 6.28 KB
/
Copy pathPackage@swift-6.2.swift
File metadata and controls
189 lines (182 loc) · 6.28 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
import Foundation
let package = Package(
name: "argmax-oss-swift",
platforms: [
.iOS(.v16),
.macOS(.v13),
.watchOS(.v10),
.visionOS(.v1)
],
products: [
.library(
name: "ArgmaxOSS",
targets: ["ArgmaxOSS"]
),
.library(
name: "WhisperKit",
targets: ["WhisperKit"]
),
.library(
name: "TTSKit",
targets: ["TTSKit"]
),
.library(
name: "SpeakerKit",
targets: ["SpeakerKit"]
),
.library(
name: "ArgmaxOSSDynamic",
type: .dynamic,
targets: ["ArgmaxOSS"]
),
.executable(
name: "argmax-cli",
targets: ["ArgmaxCLI"]
),
.executable(
name: "whisperkit-cli",
targets: ["ArgmaxCLI"]
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.7.0"),
] + (isServerEnabled() ? [
.package(url: "https://github.com/vapor/vapor.git", from: "4.115.1"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.10.2"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.8.2"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.1"),
] : []),
targets: [
.target(
name: "ArgmaxOSS",
dependencies: [
"ArgmaxCore",
"WhisperKit",
"TTSKit",
"SpeakerKit",
],
swiftSettings: swiftSettings()
),
.target(
name: "ArgmaxCore",
swiftSettings: swiftSettings()
),
.target(
name: "WhisperKit",
dependencies: [
"ArgmaxCore",
],
swiftSettings: swiftSettings()
),
.target(
name: "TTSKit",
dependencies: [
"ArgmaxCore",
],
swiftSettings: swiftSettings()
),
.target(
name: "SpeakerKit",
dependencies: [
"ArgmaxCore",
"WhisperKit",
],
swiftSettings: swiftSettings()
),
.testTarget(
name: "ArgmaxCoreTests",
dependencies: [
"ArgmaxCore",
],
resources: [
.process("External/Resources"),
],
swiftSettings: swiftSettings(libraryEvolution: false)
),
.testTarget(
name: "WhisperKitTests",
dependencies: [
"WhisperKit",
],
exclude: ["UnitTestsPlan.xctestplan"],
resources: [
.process("Resources"),
],
swiftSettings: swiftSettings(libraryEvolution: false)
),
.testTarget(
name: "TTSKitTests",
dependencies: [
"TTSKit"
],
swiftSettings: swiftSettings(libraryEvolution: false)
),
.testTarget(
name: "SpeakerKitTests",
dependencies: [
"SpeakerKit",
"WhisperKit",
],
resources: [
.process("Resources"),
],
swiftSettings: swiftSettings(libraryEvolution: false)
),
.executableTarget(
name: "ArgmaxCLI",
dependencies: [
"WhisperKit",
"TTSKit",
"SpeakerKit",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
] + (isServerEnabled() ? [
.product(name: "Vapor", package: "vapor"),
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
.product(name: "OpenAPIVapor", package: "swift-openapi-vapor"),
] : []),
path: "Sources/ArgmaxCLI",
exclude: (isServerEnabled() ? [] : ["Server"]),
swiftSettings: swiftSettings(libraryEvolution: false) + (isServerEnabled() ? [.define("BUILD_SERVER_CLI")] : [])
)
],
swiftLanguageModes: [.v6]
)
func isServerEnabled() -> Bool {
if let enabledValue = Context.environment["BUILD_ALL"] {
return enabledValue.lowercased() == "true" || enabledValue == "1"
}
// Default disabled, change to true temporarily for local development
return false
}
func swiftSettings(libraryEvolution: Bool = true) -> [SwiftSetting] {
// Opt-in to Swift 6.2's "Approachable Concurrency" upcoming features.
// These reduce false-positive concurrency diagnostics by making the
// compiler infer isolation in places where it's almost always what the
// developer intended:
// - InferIsolatedConformances (SE-0470): a protocol conformance on a
// globally-isolated type (e.g. @MainActor) is itself inferred to be
// isolated to that same actor, instead of forcing a `nonisolated`
// conformance that can't touch the type's state.
// - NonisolatedNonsendingByDefault (SE-0461): a `nonisolated` async
// function runs on the caller's actor by default rather than hopping
// to the generic executor, avoiding spurious Sendable errors on
// arguments and return values that never actually cross actors.
let approachableConcurrencySettings: [SwiftSetting] = [
.enableUpcomingFeature("InferIsolatedConformances"),
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
]
// Equivalent to Xcode's BUILD_LIBRARY_FOR_DISTRIBUTION setting: enables
// library evolution and module stability so these targets can be linked
// against prebuilt binary frameworks (e.g. an .xcframework) without
// requiring the framework to be rebuilt for every Swift compiler version.
let dynamicSettings: [SwiftSetting] = libraryEvolution ? [
.unsafeFlags([
"-enable-library-evolution",
"-Xfrontend", "-alias-module-names-in-module-interface",
])
] : []
return approachableConcurrencySettings + dynamicSettings
}