-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPackage.swift
More file actions
84 lines (81 loc) · 2.58 KB
/
Package.swift
File metadata and controls
84 lines (81 loc) · 2.58 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
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.
import Foundation
import PackageDescription
let packageRoot = URL(fileURLWithPath: #file).deletingLastPathComponent().path
let debugLibPath = "\(packageRoot)/flow-core/target/debug/libflow.a"
let releaseLibPath = "\(packageRoot)/flow-core/target/release/libflow.a"
let buildConfiguration = (ProcessInfo.processInfo.environment["SWIFT_BUILD_CONFIGURATION"]
?? ProcessInfo.processInfo.environment["CONFIGURATION"])?.lowercased()
let preferRelease = buildConfiguration == "release"
let rustLibPath: String = {
let fileManager = FileManager.default
if preferRelease {
if fileManager.fileExists(atPath: releaseLibPath) {
return releaseLibPath
}
return debugLibPath
}
if fileManager.fileExists(atPath: debugLibPath) {
return debugLibPath
}
return releaseLibPath
}()
let package = Package(
name: "Flow",
platforms: [
.macOS(.v14),
],
products: [
.library(
name: "libflow",
targets: ["Flow"]
),
.executable(
name: "Flow",
targets: ["FlowApp"]
),
],
dependencies: [],
targets: [
// C wrapper for the Rust FFI
.target(
name: "CFlow",
path: "Sources/CFlow",
publicHeadersPath: "include",
linkerSettings: [
// Link to the Rust static library
.unsafeFlags([rustLibPath]),
// System frameworks needed by the Rust library
.linkedFramework("CoreAudio"),
.linkedFramework("AudioToolbox"),
.linkedFramework("Security"),
.linkedFramework("SystemConfiguration"),
// Metal frameworks for Candle GPU acceleration
.linkedFramework("Metal"),
.linkedFramework("MetalKit"),
.linkedFramework("MetalPerformanceShaders"),
.linkedFramework("Accelerate"),
.linkedFramework("Foundation"),
]
),
// Swift wrapper
.target(
name: "Flow",
dependencies: ["CFlow"],
path: "Sources/Flow"
),
// macOS App
.executableTarget(
name: "FlowApp",
dependencies: [
"Flow",
],
path: "Sources/FlowApp",
resources: [
.process("Resources"),
.copy("../../menubar.svg"),
]
),
]
)