forked from pytorch/executorch
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPackage.swift
More file actions
Latest commit
107 lines (103 loc) · 2.84 KB
/
Copy pathPackage.swift
File metadata and controls
107 lines (103 loc) · 2.84 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// 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
import PackageDescription
letdebug="_debug"
letdeliverables=[
"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]]()){
varnewValue= $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)}
}
letpackage=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:[
.linkedLibrary("c++")
]+
(value["frameworks"]as?[String]??[]).map{.linkedFramework($0)}+
(value["libraries"]as?[String]??[]).map{.linkedLibrary($0)}
),
]
}+[
.testTarget(
name:"tests",
dependencies:[
.target(name:"executorch_debug"),
.target(name:"kernels_portable"),
],
path:"extension/apple/ExecuTorch/__tests__",
resources:[
.copy("resources/add.pte")
],
linkerSettings:[
.linkedLibrary("c++"),
.unsafeFlags([
"-Xlinker","-force_load",
"-Xlinker","cmake-out/kernels_portable.xcframework/macos-arm64/libkernels_portable_macos.a",
])
]
)
]
)