2
2
3
3
import PackageDescription
4
4
5
+ var sources = [
6
+ " ggml.c " ,
7
+ " llama.cpp " ,
8
+ " unicode.cpp " ,
9
+ " unicode-data.cpp " ,
10
+ " ggml-alloc.c " ,
11
+ " ggml-backend.c " ,
12
+ " ggml-quants.c " ,
13
+ ]
14
+
15
+ var resources : [ Resource ] = [ ]
16
+ var linkerSettings : [ LinkerSetting ] = [ ]
17
+ var cSettings : [ CSetting ] = [
18
+ . unsafeFlags( [ " -Wno-shorten-64-to-32 " , " -O3 " , " -DNDEBUG " ] ) ,
19
+ . unsafeFlags( [ " -fno-objc-arc " ] ) ,
20
+ // NOTE: NEW_LAPACK will required iOS version 16.4+
21
+ // We should consider add this in the future when we drop support for iOS 14
22
+ // (ref: ref: https://developer.apple.com/documentation/accelerate/1513264-cblas_sgemm?language=objc)
23
+ // .define("ACCELERATE_NEW_LAPACK"),
24
+ // .define("ACCELERATE_LAPACK_ILP64")
25
+ ]
26
+
27
+ #if canImport(Darwin)
28
+ sources. append ( " ggml-metal.m " )
29
+ resources. append ( . process( " ggml-metal.metal " ) )
30
+ linkerSettings. append ( . linkedFramework( " Accelerate " ) )
31
+ cSettings. append (
32
+ contentsOf: [
33
+ . define( " GGML_USE_ACCELERATE " ) ,
34
+ . define( " GGML_USE_METAL " )
35
+ ]
36
+ )
37
+ #endif
38
+
39
+ #if os(Linux)
40
+ cSettings. append ( . define( " _GNU_SOURCE " ) )
41
+ #endif
42
+
5
43
let package = Package (
6
44
name: " llama " ,
7
45
platforms: [
@@ -28,34 +66,11 @@ let package = Package(
28
66
" ggml-cuda.h " ,
29
67
" Makefile "
30
68
] ,
31
- sources: [
32
- " ggml.c " ,
33
- " llama.cpp " ,
34
- " unicode.cpp " ,
35
- " unicode-data.cpp " ,
36
- " ggml-alloc.c " ,
37
- " ggml-backend.c " ,
38
- " ggml-quants.c " ,
39
- " ggml-metal.m " ,
40
- ] ,
41
- resources: [
42
- . process( " ggml-metal.metal " )
43
- ] ,
69
+ sources: sources,
70
+ resources: resources,
44
71
publicHeadersPath: " spm-headers " ,
45
- cSettings: [
46
- . unsafeFlags( [ " -Wno-shorten-64-to-32 " , " -O3 " , " -DNDEBUG " ] ) ,
47
- . define( " GGML_USE_ACCELERATE " ) ,
48
- . unsafeFlags( [ " -fno-objc-arc " ] ) ,
49
- . define( " GGML_USE_METAL " ) ,
50
- // NOTE: NEW_LAPACK will required iOS version 16.4+
51
- // We should consider add this in the future when we drop support for iOS 14
52
- // (ref: ref: https://developer.apple.com/documentation/accelerate/1513264-cblas_sgemm?language=objc)
53
- // .define("ACCELERATE_NEW_LAPACK"),
54
- // .define("ACCELERATE_LAPACK_ILP64")
55
- ] ,
56
- linkerSettings: [
57
- . linkedFramework( " Accelerate " )
58
- ]
72
+ cSettings: cSettings,
73
+ linkerSettings: linkerSettings
59
74
)
60
75
] ,
61
76
cxxLanguageStandard: . cxx11
0 commit comments