Skip to content

Commit a66fd17

Browse files
owenvtonyarnold
andauthored
Formally adopt Swift 6 in targets which have fully migrated (swiftlang#69)
* Formally adopt Swift 6 in targets which have fully migrated * Package.swift - fix indenting Co-authored-by: Tony Arnold <tony@thecocoabots.com> --------- Co-authored-by: Tony Arnold <tony@thecocoabots.com>
1 parent b65643a commit a66fd17

File tree

1 file changed

+87
-70
lines changed

1 file changed

+87
-70
lines changed

Package.swift

Lines changed: 87 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,40 @@ let appleOS = false
2323
let useLocalDependencies = Context.environment["SWIFTCI_USE_LOCAL_DEPS"] != nil
2424
let useLLBuildFramework = Context.environment["SWIFTBUILD_LLBUILD_FWK"] != nil
2525

26-
let swiftSettings: [SwiftSetting] = [
27-
// Upcoming Swift 6.0 features
28-
.enableUpcomingFeature("ConciseMagicFile"),
29-
.enableUpcomingFeature("DeprecateApplicationMain"),
30-
.enableUpcomingFeature("DisableOutwardActorInference"),
31-
.enableUpcomingFeature("ForwardTrailingClosures"),
32-
.enableUpcomingFeature("GlobalConcurrency"),
33-
.enableUpcomingFeature("ImplicitOpenExistentials"),
34-
.enableUpcomingFeature("ImportObjcForwardDeclarations"),
35-
.enableUpcomingFeature("InferSendableFromCaptures"),
36-
.enableUpcomingFeature("IsolatedDefaultValues"),
37-
//.enableUpcomingFeature("RegionBasedIsolation"), // rdar://137809703
26+
func swiftSettings(languageMode: SwiftLanguageMode) -> [SwiftSetting] {
27+
switch languageMode {
28+
case .v5:
29+
return [
30+
// Upcoming Swift 6.0 features
31+
.enableUpcomingFeature("ConciseMagicFile"),
32+
.enableUpcomingFeature("DeprecateApplicationMain"),
33+
.enableUpcomingFeature("DisableOutwardActorInference"),
34+
.enableUpcomingFeature("ForwardTrailingClosures"),
35+
.enableUpcomingFeature("GlobalConcurrency"),
36+
.enableUpcomingFeature("ImplicitOpenExistentials"),
37+
.enableUpcomingFeature("ImportObjcForwardDeclarations"),
38+
.enableUpcomingFeature("InferSendableFromCaptures"),
39+
.enableUpcomingFeature("IsolatedDefaultValues"),
40+
//.enableUpcomingFeature("RegionBasedIsolation"), // rdar://137809703
3841

39-
// Future Swift features
40-
.enableUpcomingFeature("ExistentialAny"),
41-
.enableUpcomingFeature("InternalImportsByDefault"),
42-
]
42+
// Future Swift features
43+
.enableUpcomingFeature("ExistentialAny"),
44+
.enableUpcomingFeature("InternalImportsByDefault"),
45+
46+
.swiftLanguageMode(.v5)
47+
]
48+
case .v6:
49+
return [
50+
// Future Swift features
51+
.enableUpcomingFeature("ExistentialAny"),
52+
.enableUpcomingFeature("InternalImportsByDefault"),
53+
54+
.swiftLanguageMode(.v6)
55+
]
56+
default:
57+
fatalError("unexpected language mode")
58+
}
59+
}
4360

4461
let package = Package(
4562
name: "SwiftBuild",
@@ -62,19 +79,19 @@ let package = Package(
6279
"SwiftBuild",
6380
"SWBBuildServiceBundle", // the CLI needs to launch the service bundle
6481
],
65-
swiftSettings: swiftSettings),
82+
swiftSettings: swiftSettings(languageMode: .v6)),
6683
.executableTarget(
6784
name: "SWBBuildServiceBundle",
6885
dependencies: [
6986
"SWBBuildService", "SWBBuildSystem", "SWBServiceCore", "SWBUtil", "SWBCore",
7087
],
71-
swiftSettings: swiftSettings),
88+
swiftSettings: swiftSettings(languageMode: .v6)),
7289

7390
// Libraries
7491
.target(
7592
name: "SwiftBuild",
7693
dependencies: ["SWBCSupport", "SWBCore", "SWBProtocol", "SWBUtil", "SWBProjectModel"],
77-
swiftSettings: swiftSettings),
94+
swiftSettings: swiftSettings(languageMode: .v5)),
7895
.target(
7996
name: "SWBBuildService",
8097
dependencies: [
@@ -83,11 +100,11 @@ let package = Package(
83100
"SWBTaskExecution",
84101
.product(name: "SystemPackage", package: "swift-system", condition: .when(platforms: [.linux, .android, .windows])),
85102
],
86-
swiftSettings: swiftSettings),
103+
swiftSettings: swiftSettings(languageMode: .v5)),
87104
.target(
88105
name: "SWBBuildSystem",
89106
dependencies: ["SWBCore", "SWBTaskConstruction", "SWBTaskExecution"],
90-
swiftSettings: swiftSettings),
107+
swiftSettings: swiftSettings(languageMode: .v5)),
91108
.target(
92109
name: "SWBCore",
93110
dependencies: [
@@ -99,7 +116,7 @@ let package = Package(
99116
.product(name: "SwiftDriver", package: "swift-driver"),
100117
"SWBLLBuild",
101118
],
102-
swiftSettings: swiftSettings,
119+
swiftSettings: swiftSettings(languageMode: .v5),
103120
plugins: [
104121
.plugin(name: "SWBSpecificationsPlugin")
105122
]),
@@ -110,16 +127,16 @@ let package = Package(
110127
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])),
111128
.define("_CRT_NONSTDC_NO_WARNINGS", .when(platforms: [.windows])),
112129
],
113-
swiftSettings: swiftSettings),
130+
swiftSettings: swiftSettings(languageMode: .v6)),
114131
.target(
115132
name: "SWBCLibc",
116133
exclude: ["README.md"],
117134
publicHeadersPath: ".",
118-
swiftSettings: swiftSettings),
135+
swiftSettings: swiftSettings(languageMode: .v6)),
119136
.target(
120137
name: "SWBLibc",
121138
dependencies: ["SWBCLibc"],
122-
swiftSettings: swiftSettings),
139+
swiftSettings: swiftSettings(languageMode: .v6)),
123140
.target(
124141
name: "SWBLLBuild",
125142
dependencies: [
@@ -128,34 +145,34 @@ let package = Package(
128145
.product(name: "libllbuild", package: useLocalDependencies ? "llbuild" : "swift-llbuild"),
129146
.product(name: "llbuildSwift", package: useLocalDependencies ? "llbuild" : "swift-llbuild"),
130147
]),
131-
swiftSettings: swiftSettings),
148+
swiftSettings: swiftSettings(languageMode: .v6)),
132149
.target(
133150
name: "SWBMacro",
134151
dependencies: [
135152
"SWBUtil",
136153
.product(name: "SwiftDriver", package: "swift-driver"),
137154
],
138-
swiftSettings: swiftSettings),
155+
swiftSettings: swiftSettings(languageMode: .v6)),
139156
.target(
140157
name: "SWBProjectModel",
141158
dependencies: ["SWBProtocol"],
142-
swiftSettings: swiftSettings),
159+
swiftSettings: swiftSettings(languageMode: .v6)),
143160
.target(
144161
name: "SWBProtocol",
145162
dependencies: ["SWBUtil"],
146-
swiftSettings: swiftSettings),
163+
swiftSettings: swiftSettings(languageMode: .v6)),
147164
.target(
148165
name: "SWBServiceCore",
149166
dependencies: ["SWBProtocol"],
150-
swiftSettings: swiftSettings),
167+
swiftSettings: swiftSettings(languageMode: .v6)),
151168
.target(
152169
name: "SWBTaskConstruction",
153170
dependencies: ["SWBCore", "SWBUtil"],
154-
swiftSettings: swiftSettings),
171+
swiftSettings: swiftSettings(languageMode: .v5)),
155172
.target(
156173
name: "SWBTaskExecution",
157174
dependencies: ["SWBCore", "SWBUtil", "SWBCAS", "SWBLLBuild", "SWBTaskConstruction"],
158-
swiftSettings: swiftSettings),
175+
swiftSettings: swiftSettings(languageMode: .v5)),
159176
.target(
160177
name: "SWBUtil",
161178
dependencies: [
@@ -165,41 +182,41 @@ let package = Package(
165182
.product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.linux, .android])),
166183
.product(name: "SystemPackage", package: "swift-system", condition: .when(platforms: [.linux, .android, .windows])),
167184
],
168-
swiftSettings: swiftSettings),
185+
swiftSettings: swiftSettings(languageMode: .v5)),
169186
.target(
170187
name: "SWBCAS",
171188
dependencies: ["SWBUtil", "SWBCSupport"],
172-
swiftSettings: swiftSettings),
189+
swiftSettings: swiftSettings(languageMode: .v6)),
173190

174191
.target(
175192
name: "SWBAndroidPlatform",
176193
dependencies: ["SWBCore"],
177-
swiftSettings: swiftSettings),
194+
swiftSettings: swiftSettings(languageMode: .v6)),
178195
.target(
179196
name: "SWBApplePlatform",
180197
dependencies: ["SWBCore", "SWBTaskConstruction"],
181-
swiftSettings: swiftSettings),
198+
swiftSettings: swiftSettings(languageMode: .v5)),
182199
.target(
183200
name: "SWBGenericUnixPlatform",
184201
dependencies: ["SWBCore"],
185-
swiftSettings: swiftSettings),
202+
swiftSettings: swiftSettings(languageMode: .v6)),
186203
.target(
187204
name: "SWBQNXPlatform",
188205
dependencies: ["SWBCore"],
189-
swiftSettings: swiftSettings),
206+
swiftSettings: swiftSettings(languageMode: .v6)),
190207
.target(
191208
name: "SWBUniversalPlatform",
192209
dependencies: ["SWBCore"],
193-
swiftSettings: swiftSettings),
210+
swiftSettings: swiftSettings(languageMode: .v6)),
194211
.target(
195212
name: "SWBWindowsPlatform",
196213
dependencies: ["SWBCore"],
197-
swiftSettings: swiftSettings),
214+
swiftSettings: swiftSettings(languageMode: .v6)),
198215

199216
// Helper targets for SwiftPM
200217
.executableTarget(
201218
name: "SWBSpecificationsCompiler",
202-
swiftSettings: swiftSettings),
219+
swiftSettings: swiftSettings(languageMode: .v6)),
203220
.plugin(
204221
name: "SWBSpecificationsPlugin",
205222
capability: .buildTool(),
@@ -209,11 +226,11 @@ let package = Package(
209226
.target(
210227
name: "SwiftBuildTestSupport",
211228
dependencies: ["SwiftBuild", "SWBTestSupport", "SWBUtil"],
212-
swiftSettings: swiftSettings),
229+
swiftSettings: swiftSettings(languageMode: .v6)),
213230
.target(
214231
name: "SWBTestSupport",
215232
dependencies: ["SwiftBuild", "SWBBuildSystem", "SWBCore", "SWBTaskConstruction", "SWBTaskExecution", "SWBUtil", "SWBLLBuild", "SWBMacro"],
216-
swiftSettings: swiftSettings + [
233+
swiftSettings: swiftSettings(languageMode: .v5) + [
217234
// Temporary until swift-testing introduces replacement for this SPI
218235
.define("DONT_HAVE_CUSTOM_EXECUTION_TRAIT", .when(platforms: [.macOS, .macCatalyst, .iOS, .tvOS, .watchOS, .visionOS, .windows]))
219236
]),
@@ -222,118 +239,118 @@ let package = Package(
222239
.testTarget(
223240
name: "SWBAndroidPlatformTests",
224241
dependencies: ["SWBAndroidPlatform", "SWBTestSupport"],
225-
swiftSettings: swiftSettings),
242+
swiftSettings: swiftSettings(languageMode: .v6)),
226243
.testTarget(
227244
name: "SWBApplePlatformTests",
228245
dependencies: ["SWBApplePlatform", "SWBTestSupport"],
229-
swiftSettings: swiftSettings),
246+
swiftSettings: swiftSettings(languageMode: .v6)),
230247
.testTarget(
231248
name: "SWBGenericUnixPlatformTests",
232249
dependencies: ["SWBGenericUnixPlatform", "SWBTestSupport"],
233-
swiftSettings: swiftSettings),
250+
swiftSettings: swiftSettings(languageMode: .v6)),
234251
.testTarget(
235252
name: "SWBQNXPlatformTests",
236253
dependencies: ["SWBQNXPlatform", "SWBTestSupport"],
237-
swiftSettings: swiftSettings),
254+
swiftSettings: swiftSettings(languageMode: .v6)),
238255
.testTarget(
239256
name: "SWBUniversalPlatformTests",
240257
dependencies: ["SWBUniversalPlatform", "SWBTestSupport"],
241-
swiftSettings: swiftSettings),
258+
swiftSettings: swiftSettings(languageMode: .v6)),
242259
.testTarget(
243260
name: "SWBWindowsPlatformTests",
244261
dependencies: ["SWBWindowsPlatform", "SWBTestSupport"],
245-
swiftSettings: swiftSettings),
262+
swiftSettings: swiftSettings(languageMode: .v6)),
246263
.testTarget(
247264
name: "SwiftBuildTests",
248265
dependencies: ["SwiftBuild", "SWBBuildService", "SwiftBuildTestSupport"],
249266
resources: [
250267
.copy("TestData")
251268
],
252-
swiftSettings: swiftSettings),
269+
swiftSettings: swiftSettings(languageMode: .v6)),
253270
.testTarget(
254271
name: "SWBProjectModelTests",
255272
dependencies: ["SWBProjectModel"],
256-
swiftSettings: swiftSettings),
273+
swiftSettings: swiftSettings(languageMode: .v6)),
257274
.testTarget(
258275
name: "SWBProtocolTests",
259276
dependencies: ["SWBProtocol", "SWBUtil"],
260-
swiftSettings: swiftSettings),
277+
swiftSettings: swiftSettings(languageMode: .v6)),
261278
.testTarget(
262279
name: "SWBUtilTests",
263280
dependencies: ["SWBTestSupport", "SWBUtil"],
264-
swiftSettings: swiftSettings),
281+
swiftSettings: swiftSettings(languageMode: .v6)),
265282
.testTarget(
266283
name: "SWBCASTests",
267284
dependencies: ["SWBTestSupport", "SWBCAS", "SWBUtil"],
268-
swiftSettings: swiftSettings),
285+
swiftSettings: swiftSettings(languageMode: .v6)),
269286
.testTarget(
270287
name: "SWBMacroTests",
271288
dependencies: ["SWBTestSupport", "SWBMacro"],
272-
swiftSettings: swiftSettings),
289+
swiftSettings: swiftSettings(languageMode: .v6)),
273290
.testTarget(
274291
name: "SWBServiceCoreTests",
275292
dependencies: ["SWBServiceCore"],
276-
swiftSettings: swiftSettings),
293+
swiftSettings: swiftSettings(languageMode: .v6)),
277294
.testTarget(
278295
name: "SWBCoreTests",
279296
dependencies: ["SWBCore", "SWBTestSupport", "SWBUtil", "SWBLLBuild"],
280-
swiftSettings: swiftSettings),
297+
swiftSettings: swiftSettings(languageMode: .v6)),
281298
.testTarget(
282299
name: "SWBTaskConstructionTests",
283300
dependencies: ["SWBTaskConstruction", "SWBCore", "SWBTestSupport", "SWBProtocol", "SWBUtil"],
284-
swiftSettings: swiftSettings),
301+
swiftSettings: swiftSettings(languageMode: .v6)),
285302
.testTarget(
286303
name: "SWBTaskExecutionTests",
287304
dependencies: ["SWBTaskExecution", "SWBTestSupport"],
288305
resources: [
289306
.copy("TestData")
290307
],
291-
swiftSettings: swiftSettings),
308+
swiftSettings: swiftSettings(languageMode: .v6)),
292309
.testTarget(
293310
name: "SWBLLBuildTests",
294311
dependencies: ["SWBLLBuild", "SWBTestSupport"],
295-
swiftSettings: swiftSettings),
312+
swiftSettings: swiftSettings(languageMode: .v6)),
296313
.testTarget(
297314
name: "SWBBuildSystemTests",
298315
dependencies: ["SWBBuildService", "SWBBuildSystem", "SwiftBuildTestSupport", "SWBTestSupport"],
299316
resources: [
300317
.copy("TestData")
301318
],
302-
swiftSettings: swiftSettings),
319+
swiftSettings: swiftSettings(languageMode: .v6)),
303320
.testTarget(
304321
name: "SWBBuildServiceTests",
305322
dependencies: ["SwiftBuild", "SWBBuildService", "SWBTestSupport"],
306-
swiftSettings: swiftSettings),
323+
swiftSettings: swiftSettings(languageMode: .v6)),
307324
.testTarget(
308325
name: "SWBTestSupportTests",
309326
dependencies: ["SWBTestSupport"],
310-
swiftSettings: swiftSettings),
327+
swiftSettings: swiftSettings(languageMode: .v6)),
311328

312329
// Perf tests
313330
.testTarget(
314331
name: "SWBBuildSystemPerfTests",
315332
dependencies: ["SWBBuildSystem", "SWBTestSupport"],
316-
swiftSettings: swiftSettings),
333+
swiftSettings: swiftSettings(languageMode: .v6)),
317334
.testTarget(
318335
name: "SWBCASPerfTests",
319336
dependencies: ["SWBCAS", "SWBTestSupport"],
320-
swiftSettings: swiftSettings),
337+
swiftSettings: swiftSettings(languageMode: .v6)),
321338
.testTarget(
322339
name: "SWBCorePerfTests",
323340
dependencies: ["SWBCore", "SWBTestSupport"],
324-
swiftSettings: swiftSettings),
341+
swiftSettings: swiftSettings(languageMode: .v6)),
325342
.testTarget(
326343
name: "SWBTaskConstructionPerfTests",
327344
dependencies: ["SWBTaskConstruction", "SWBTestSupport"],
328-
swiftSettings: swiftSettings),
345+
swiftSettings: swiftSettings(languageMode: .v6)),
329346
.testTarget(
330347
name: "SWBUtilPerfTests",
331348
dependencies: ["SWBUtil", "SWBTestSupport"],
332-
swiftSettings: swiftSettings),
349+
swiftSettings: swiftSettings(languageMode: .v6)),
333350
.testTarget(
334351
name: "SwiftBuildPerfTests",
335352
dependencies: ["SwiftBuild", "SWBTestSupport", "SwiftBuildTestSupport"],
336-
swiftSettings: swiftSettings),
353+
swiftSettings: swiftSettings(languageMode: .v6)),
337354

338355
// Commands
339356
.plugin(
@@ -344,7 +361,7 @@ let package = Package(
344361
))
345362
)
346363
],
347-
swiftLanguageModes: [.v5],
364+
swiftLanguageModes: [.v6],
348365
cxxLanguageStandard: .cxx20
349366
)
350367

0 commit comments

Comments
 (0)