Skip to content

Add standard libs and frameworks deps to Swift PM manifest. #2568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file added .swift/executorch/dummy.swift
Empty file.
Empty file added .swift/mps_backend/dummy.swift
Empty file.
Empty file.
Empty file.
35 changes: 29 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ let xnnpack_sha256 = "3fd6e4e1d9687eb25e2638bb3dfbc429b736cbf47e7ed769f1dbec6225
struct Framework {
let name: String
let checksum: String
var frameworks: [String] = []
var libraries: [String] = []

func target() -> Target {
.binaryTarget(
Expand All @@ -28,20 +30,43 @@ struct Framework {
checksum: checksum
)
}

func dependencies() -> Target {
.target(
name: "\(name)_dependencies",
dependencies: [.target(name: name)],
path: ".swift/\(name)",
linkerSettings:
frameworks.map { .linkedFramework($0) } +
libraries.map { .linkedLibrary($0) }
)
}
}

let frameworks = [
Framework(
name: "coreml_backend",
checksum: coreml_sha256
checksum: coreml_sha256,
frameworks: [
"Accelerate",
"CoreML",
],
libraries: [
"sqlite3",
]
),
Framework(
name: "executorch",
checksum: executorch_sha256
),
Framework(
name: "mps_backend",
checksum: mps_sha256
checksum: mps_sha256,
frameworks: [
"Metal",
"MetalPerformanceShaders",
"MetalPerformanceShadersGraph",
]
),
Framework(
name: "portable_backend",
Expand All @@ -58,8 +83,6 @@ let package = Package(
platforms: [
.iOS(.v15),
],
products: frameworks.map { framework in
.library(name: framework.name, targets: [framework.name])
},
targets: frameworks.map { $0.target() }
products: frameworks.map { .library(name: $0.name, targets: ["\($0.name)_dependencies"]) },
targets: frameworks.flatMap { [$0.target(), $0.dependencies()] }
)