Skip to content

Commit f8c9d92

Browse files
committed
Add parser library for 0.50600.0-prerelease-2022-01-24
1 parent d71bef5 commit f8c9d92

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Package.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ if ProcessInfo.processInfo.environment["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] != nil
2020
swiftSyntaxUnsafeSwiftFlags += ["-enforce-exclusivity=unchecked"]
2121
}
2222

23+
// Include the parser library as a binary dependency if both the host and the target are macOS.
24+
// - We need to require that the host is macOS (checked by `#if os(macOS)`) because package resolve will download and unzip the referenced framework, which requires `unzip` to be installed. Only macOS guarantees that `unzip` is installed, the Swift Docker images don’t have unzip installed, so package resolve would fail.
25+
// - We need to require that the target is macOS (checked by `.when`) because binary dependencies are only supported by SwiftPM on macOS.
26+
#if os(macOS)
27+
let parserLibraryTarget: [Target] = [.binaryTarget(
28+
name: "_InternalSwiftSyntaxParser",
29+
url: "https://github.com/apple/swift-syntax/releases/download/0.50600.0-SNAPSHOT-2022-01-24/_InternalSwiftSyntaxParser.xcframework.zip",
30+
checksum: "6d0a1b471cd5179f2669b46040d9e8aa92de31f7f82a9b096a2ee3e5d0c7afc1"
31+
)]
32+
let parserLibraryDependency: [Target.Dependency] = [.target(name: "_InternalSwiftSyntaxParser", condition: .when(platforms: [.macOS]))]
33+
#else
34+
let parserLibraryTarget: [Target] = []
35+
let parserLibraryDependency: [Target.Dependency] = []
36+
#endif
37+
2338
let package = Package(
2439
name: "SwiftSyntax",
2540
products: [
@@ -31,7 +46,7 @@ let package = Package(
3146
.target(name: "_CSwiftSyntax"),
3247
.target(
3348
name: "SwiftSyntax",
34-
dependencies: ["_CSwiftSyntax"],
49+
dependencies: ["_CSwiftSyntax"] + parserLibraryDependency,
3550
exclude: [
3651
"SyntaxFactory.swift.gyb",
3752
"SyntaxTraits.swift.gyb",
@@ -91,5 +106,5 @@ let package = Package(
91106
dependencies: ["SwiftSyntax", "SwiftSyntaxParser"],
92107
exclude: ["Inputs"]
93108
),
94-
]
109+
] + parserLibraryTarget
95110
)

0 commit comments

Comments
 (0)