-
Notifications
You must be signed in to change notification settings - Fork 489
/
Copy pathPackage.swift
86 lines (82 loc) · 2.29 KB
/
Package.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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) }
),
]
}
)