|  | 
| 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: "llama", | 
| 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: "llama", targets: ["llama"]), | 
| 34 | 15 |     ], | 
| 35 | 16 |     targets: [ | 
| 36 | 17 |         .target( | 
| 37 | 18 |             name: "llama", | 
| 38 | 19 |             path: ".", | 
| 39 |  | -            exclude: exclude, | 
|  | 20 | +            exclude: [], | 
| 40 | 21 |             sources: [ | 
| 41 | 22 |                 "ggml.c", | 
| 42 | 23 |                 "llama.cpp", | 
| 43 | 24 |                 "ggml-alloc.c", | 
| 44 | 25 |                 "ggml-backend.c", | 
| 45 | 26 |                 "ggml-quants.c", | 
| 46 |  | -            ] + additionalSources, | 
| 47 |  | -            resources: resources, | 
|  | 27 | +                "ggml-metal.m", | 
|  | 28 | +            ], | 
|  | 29 | +            resources: [ | 
|  | 30 | +                .process("ggml-metal.metal") | 
|  | 31 | +            ], | 
| 48 | 32 |             publicHeadersPath: "spm-headers", | 
| 49 | 33 |             cSettings: [ | 
| 50 | 34 |                 .unsafeFlags(["-Wno-shorten-64-to-32", "-O3", "-DNDEBUG"]), | 
| 51 |  | -                .define("GGML_USE_ACCELERATE") | 
|  | 35 | +                .define("GGML_USE_ACCELERATE"), | 
|  | 36 | +                .unsafeFlags(["-fno-objc-arc"]), | 
|  | 37 | +                .define("GGML_USE_METAL"), | 
| 52 | 38 |                 // NOTE: NEW_LAPACK will required iOS version 16.4+ | 
| 53 | 39 |                 // We should consider add this in the future when we drop support for iOS 14 | 
| 54 | 40 |                 // (ref: ref: https://developer.apple.com/documentation/accelerate/1513264-cblas_sgemm?language=objc) | 
| 55 | 41 |                 // .define("ACCELERATE_NEW_LAPACK"), | 
| 56 | 42 |                 // .define("ACCELERATE_LAPACK_ILP64") | 
| 57 |  | -            ] + additionalSettings, | 
|  | 43 | +            ], | 
| 58 | 44 |             linkerSettings: [ | 
| 59 | 45 |                 .linkedFramework("Accelerate") | 
| 60 | 46 |             ] | 
|  | 
0 commit comments