Skip to content

Commit db882fe

Browse files
ahoppendduan
authored andcommitted
Add parser library for 0.50600.0
1 parent 87d6d0a commit db882fe

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/_InternalSwiftSyntaxParser.xcframework.zip",
30+
checksum: "0e0d9ecbfddd0765485ded160beb9e7657e7add9d5ffd98ef61e8bd0c967e3a9"
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",
@@ -87,5 +102,5 @@ let package = Package(
87102
dependencies: ["SwiftSyntax", "SwiftSyntaxParser"],
88103
exclude: ["Inputs"]
89104
),
90-
]
105+
] + parserLibraryTarget
91106
)

0 commit comments

Comments
 (0)