Skip to content

Commit

Permalink
Add parser library for 0.50600.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoppen committed Mar 18, 2022
1 parent 3ee10cc commit 0b6c22b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ if ProcessInfo.processInfo.environment["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] != nil
swiftSyntaxSwiftSettings = []
}

// Include the parser library as a binary dependency if both the host and the target are macOS.
// - 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.
// - We need to require that the target is macOS (checked by `.when`) because binary dependencies are only supported by SwiftPM on macOS.
#if os(macOS)
let parserLibraryTarget: [Target] = [.binaryTarget(
name: "_InternalSwiftSyntaxParser",
url: "https://github.com/apple/swift-syntax/releases/download/0.50600.1/_InternalSwiftSyntaxParser.xcframework.zip",
checksum: "0e0d9ecbfddd0765485ded160beb9e7657e7add9d5ffd98ef61e8bd0c967e3a9"
)]
let parserLibraryDependency: [Target.Dependency] = [.target(name: "_InternalSwiftSyntaxParser", condition: .when(platforms: [.macOS]))]
#else
let parserLibraryTarget: [Target] = []
let parserLibraryDependency: [Target.Dependency] = []
#endif

let package = Package(
name: "SwiftSyntax",
products: [
Expand Down Expand Up @@ -65,7 +80,7 @@ let package = Package(
"Tokens.swift.gyb",
]
),
.target(name: "SwiftSyntaxParser", dependencies: ["SwiftSyntax"], exclude: [
.target(name: "SwiftSyntaxParser", dependencies: ["SwiftSyntax"] + parserLibraryDependency, exclude: [
"NodeDeclarationHash.swift.gyb"
]),
.target(
Expand All @@ -90,5 +105,5 @@ let package = Package(
dependencies: ["SwiftSyntax", "SwiftSyntaxParser"],
exclude: ["Inputs"]
),
]
] + parserLibraryTarget
)

0 comments on commit 0b6c22b

Please sign in to comment.