@@ -19,7 +19,7 @@ This allows some clients (such as IDEs) that use SwiftPM's data model but not it
19
19
to not have to depend on SwiftDriver, SwiftLLBuild, etc. We should probably have better names here,
20
20
though that could break some clients.
21
21
*/
22
- let swiftPMDataModelProduct = (
22
+ var swiftPMDataModelProduct = (
23
23
name: " SwiftPMDataModel " ,
24
24
targets: [
25
25
" SourceControl " ,
@@ -33,6 +33,10 @@ let swiftPMDataModelProduct = (
33
33
]
34
34
)
35
35
36
+ #if compiler(>=5.5)
37
+ swiftPMDataModelProduct. targets. append ( " PackageSyntax " )
38
+ #endif
39
+
36
40
/** The `libSwiftPM` set of interfaces to programmatically work with Swift
37
41
packages. `libSwiftPM` includes all of the SwiftPM code except the
38
42
command line tools, while `libSwiftPMDataModel` includes only the data model.
@@ -53,6 +57,14 @@ automatic linking type with `-auto` suffix appended to product's name.
53
57
*/
54
58
let autoProducts = [ swiftPMProduct, swiftPMDataModelProduct]
55
59
60
+ var commandsDependencies : [ Target . Dependency ] = [ " SwiftToolsSupport-auto " , " Basics " , " Build " , " PackageGraph " , " SourceControl " , " Xcodeproj " , " Workspace " , " XCBuildSupport " , " ArgumentParser " , " PackageCollections " ]
61
+ var commandsSwiftSettings : [ SwiftSetting ] ? = nil
62
+
63
+ #if compiler(>=5.5)
64
+ commandsDependencies. append ( " PackageSyntax " )
65
+ commandsSwiftSettings = [ . define( " BUILD_PACKAGE_SYNTAX " ) ]
66
+ #endif
67
+
56
68
let package = Package (
57
69
name: " SwiftPM " ,
58
70
platforms: [
@@ -216,7 +228,8 @@ let package = Package(
216
228
. target(
217
229
/** High-level commands */
218
230
name: " Commands " ,
219
- dependencies: [ " SwiftToolsSupport-auto " , " Basics " , " Build " , " PackageGraph " , " SourceControl " , " Xcodeproj " , " Workspace " , " XCBuildSupport " , " ArgumentParser " , " PackageCollections " ] ) ,
231
+ dependencies: commandsDependencies,
232
+ swiftSettings: commandsSwiftSettings) ,
220
233
. target(
221
234
/** The main executable provided by SwiftPM */
222
235
name: " swift-package " ,
@@ -262,7 +275,8 @@ let package = Package(
262
275
dependencies: [ " Build " , " SPMTestSupport " ] ) ,
263
276
. testTarget(
264
277
name: " CommandsTests " ,
265
- dependencies: [ " swift-build " , " swift-package " , " swift-test " , " swift-run " , " Commands " , " Workspace " , " SPMTestSupport " , " Build " , " SourceControl " ] ) ,
278
+ dependencies: [ " swift-build " , " swift-package " , " swift-test " , " swift-run " , " Commands " , " Workspace " , " SPMTestSupport " , " Build " , " SourceControl " ] ,
279
+ swiftSettings: commandsSwiftSettings) ,
266
280
. testTarget(
267
281
name: " WorkspaceTests " ,
268
282
dependencies: [ " Workspace " , " SPMTestSupport " ] ) ,
@@ -370,3 +384,24 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
370
384
. package ( path: " ../swift-collections " ) ,
371
385
]
372
386
}
387
+
388
+
389
+ #if compiler(>=5.5)
390
+ // SwiftSyntax depends on lib_InternalSwiftSyntaxParser from the toolchain,
391
+ // which had an ABI break in Swift 5.5. As a result, we shouldn't attempt to
392
+ // compile PackageSyntax with an earlier compiler version. Although PackageSyntax
393
+ // should compile with any 5.5 compiler, it will only be functional when built
394
+ // with a toolchain that has a compatible parser library.
395
+ if ProcessInfo . processInfo. environment [ " SWIFTCI_USE_LOCAL_DEPS " ] == nil {
396
+ package . dependencies += [ . package ( url: " https://github.com/apple/swift-syntax.git " , . branch( " release/5.5 " ) ) ]
397
+ } else {
398
+ package . dependencies += [ . package ( path: " ../swift-syntax " ) ]
399
+ }
400
+
401
+ package . targets += [
402
+ . target( name: " PackageSyntax " ,
403
+ dependencies: [ " Workspace " , " PackageModel " , " PackageLoading " ,
404
+ " SourceControl " , " SwiftSyntax " , " SwiftToolsSupport-auto " ] ) ,
405
+ . testTarget( name: " PackageSyntaxTests " , dependencies: [ " PackageSyntax " , " SPMTestSupport " , " SwiftSyntax " ] ) ,
406
+ ]
407
+ #endif
0 commit comments