Skip to content

Commit 0b6c22b

Browse files
committed
Add parser library for 0.50600.1
1 parent 3ee10cc commit 0b6c22b

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
@@ -23,6 +23,21 @@ if ProcessInfo.processInfo.environment["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] != nil
2323
swiftSyntaxSwiftSettings = []
2424
}
2525

26+
// Include the parser library as a binary dependency if both the host and the target are macOS.
27+
// - 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.
28+
// - We need to require that the target is macOS (checked by `.when`) because binary dependencies are only supported by SwiftPM on macOS.
29+
#if os(macOS)
30+
let parserLibraryTarget: [Target] = [.binaryTarget(
31+
name: "_InternalSwiftSyntaxParser",
32+
url: "https://github.com/apple/swift-syntax/releases/download/0.50600.1/_InternalSwiftSyntaxParser.xcframework.zip",
33+
checksum: "0e0d9ecbfddd0765485ded160beb9e7657e7add9d5ffd98ef61e8bd0c967e3a9"
34+
)]
35+
let parserLibraryDependency: [Target.Dependency] = [.target(name: "_InternalSwiftSyntaxParser", condition: .when(platforms: [.macOS]))]
36+
#else
37+
let parserLibraryTarget: [Target] = []
38+
let parserLibraryDependency: [Target.Dependency] = []
39+
#endif
40+
2641
let package = Package(
2742
name: "SwiftSyntax",
2843
products: [
@@ -65,7 +80,7 @@ let package = Package(
6580
"Tokens.swift.gyb",
6681
]
6782
),
68-
.target(name: "SwiftSyntaxParser", dependencies: ["SwiftSyntax"], exclude: [
83+
.target(name: "SwiftSyntaxParser", dependencies: ["SwiftSyntax"] + parserLibraryDependency, exclude: [
6984
"NodeDeclarationHash.swift.gyb"
7085
]),
7186
.target(
@@ -90,5 +105,5 @@ let package = Package(
90105
dependencies: ["SwiftSyntax", "SwiftSyntaxParser"],
91106
exclude: ["Inputs"]
92107
),
93-
]
108+
] + parserLibraryTarget
94109
)

0 commit comments

Comments
 (0)