2
2
3
3
import PackageDescription
4
4
5
- #if arch(arm) || arch(arm64)
6
- let platforms : [ SupportedPlatform ] ? = [
7
- . macOS( . v12) ,
8
- . iOS( . v14) ,
9
- . watchOS( . v4) ,
10
- . tvOS( . v14)
11
- ]
12
- let exclude : [ String ] = [ ]
13
- let resources : [ Resource ] = [
14
- . process( " ggml-metal.metal " )
15
- ]
16
- let additionalSources : [ String ] = [ " ggml-metal.m " ]
17
- let additionalSettings : [ CSetting ] = [
18
- . unsafeFlags( [ " -fno-objc-arc " ] ) ,
19
- . define( " GGML_USE_METAL " )
20
- ]
21
- #else
22
- let platforms : [ SupportedPlatform ] ? = nil
23
- let exclude : [ String ] = [ " ggml-metal.metal " ]
24
- let resources : [ Resource ] = [ ]
25
- let additionalSources : [ String ] = [ ]
26
- let additionalSettings : [ CSetting ] = [ ]
27
- #endif
28
-
29
5
let package = Package (
30
6
name: " whisper " ,
31
- platforms: platforms,
7
+ platforms: [
8
+ . macOS( . v12) ,
9
+ . iOS( . v14) ,
10
+ . watchOS( . v4) ,
11
+ . tvOS( . v14)
12
+ ] ,
32
13
products: [
33
14
. library( name: " whisper " , targets: [ " whisper " ] ) ,
34
15
] ,
35
16
targets: [
36
17
. target(
37
18
name: " whisper " ,
38
19
path: " . " ,
39
- exclude: exclude + [
20
+ exclude: [
40
21
" bindings " ,
41
22
" cmake " ,
42
23
" coreml " ,
@@ -55,19 +36,22 @@ let package = Package(
55
36
" whisper.cpp " ,
56
37
" ggml-alloc.c " ,
57
38
" ggml-backend.c " ,
58
- " ggml-quants.c "
59
- ] + additionalSources,
60
- resources: resources,
39
+ " ggml-quants.c " ,
40
+ " ggml-metal.m "
41
+ ] ,
42
+ resources: [ . process( " ggml-metal.metal " ) ] ,
61
43
publicHeadersPath: " spm-headers " ,
62
44
cSettings: [
63
45
. unsafeFlags( [ " -Wno-shorten-64-to-32 " , " -O3 " , " -DNDEBUG " ] ) ,
64
- . define( " GGML_USE_ACCELERATE " )
46
+ . define( " GGML_USE_ACCELERATE " ) ,
47
+ . unsafeFlags( [ " -fno-objc-arc " ] ) ,
48
+ . define( " GGML_USE_METAL " )
65
49
// NOTE: NEW_LAPACK will required iOS version 16.4+
66
50
// We should consider add this in the future when we drop support for iOS 14
67
51
// (ref: ref: https://developer.apple.com/documentation/accelerate/1513264-cblas_sgemm?language=objc)
68
52
// .define("ACCELERATE_NEW_LAPACK"),
69
53
// .define("ACCELERATE_LAPACK_ILP64")
70
- ] + additionalSettings ,
54
+ ] ,
71
55
linkerSettings: [
72
56
. linkedFramework( " Accelerate " )
73
57
]
0 commit comments