Skip to content
Merged
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.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
86 changes: 86 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// swift-tools-version:5.9
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

// NOTE: This package manifest is for frameworks built locally with CMake.
// It defines dependencies and linker settings for Executorch components.
//
// To use prebuilt binaries instead, switch to one of the "swiftpm" branches,
// which fetch the precompiled `.xcframeworks`.
//
// For details on building frameworks locally or using prebuilt binaries,
// see the documentation:
// https://pytorch.org/executorch/main/using-executorch-ios.html

import PackageDescription

let debug = "_debug"
let deliverables = [
"backend_coreml": [
"frameworks": [
"Accelerate",
"CoreML",
],
"libraries": [
"sqlite3",
],
],
"backend_mps": [
"frameworks": [
"Metal",
"MetalPerformanceShaders",
"MetalPerformanceShadersGraph",
],
],
"backend_xnnpack": [:],
"executorch": [:],
"kernels_custom": [:],
"kernels_optimized": [:],
"kernels_portable": [:],
"kernels_quantized": [:],
].reduce(into: [String: [String: Any]]()) {
$0[$1.key] = $1.value
$0[$1.key + debug] = $1.value
}.reduce(into: [String: [String: Any]]()) {
var newValue = $1.value
if $1.key.hasSuffix(debug) {
$1.value.forEach { key, value in
if key.hasSuffix(debug) {
newValue[String(key.dropLast(debug.count))] = value
}
}
}
$0[$1.key] = newValue.filter { key, _ in !key.hasSuffix(debug) }
}

let package = Package(
name: "executorch",
platforms: [
.iOS(.v17),
.macOS(.v10_15),
],
products: deliverables.keys.map { key in
.library(name: key, targets: ["\(key)_dependencies"])
}.sorted { $0.name < $1.name },
targets: deliverables.flatMap { key, value -> [Target] in
[
.binaryTarget(
name: key,
path: "cmake-out/\(key).xcframework"
),
.target(
name: "\(key)_dependencies",
dependencies: [.target(name: key)],
path: ".Package.swift/\(key)",
linkerSettings:
(value["frameworks"] as? [String] ?? []).map { .linkedFramework($0) } +
(value["libraries"] as? [String] ?? []).map { .linkedLibrary($0) }
),
]
}
)
Loading