2023-03-28 18:39:01 +02:00
|
|
|
// swift-tools-version:5.3
|
|
|
|
|
|
|
|
import PackageDescription
|
|
|
|
|
2023-09-09 11:12:10 +02:00
|
|
|
#if arch(arm) || arch(arm64)
|
|
|
|
let platforms: [SupportedPlatform]? = [
|
|
|
|
.macOS(.v11),
|
|
|
|
.iOS(.v14),
|
|
|
|
.watchOS(.v4),
|
|
|
|
.tvOS(.v14)
|
|
|
|
]
|
|
|
|
let exclude: [String] = []
|
|
|
|
let additionalSources: [String] = ["ggml-metal.m"]
|
|
|
|
let additionalSettings: [CSetting] = [
|
|
|
|
.unsafeFlags(["-fno-objc-arc"]),
|
|
|
|
.define("GGML_SWIFT"),
|
|
|
|
.define("GGML_USE_METAL")
|
|
|
|
]
|
|
|
|
#else
|
|
|
|
let platforms: [SupportedPlatform]? = nil
|
|
|
|
let exclude: [String] = ["ggml-metal.metal"]
|
|
|
|
let additionalSources: [String] = []
|
|
|
|
let additionalSettings: [CSetting] = []
|
|
|
|
#endif
|
|
|
|
|
2023-03-28 18:39:01 +02:00
|
|
|
let package = Package(
|
|
|
|
name: "llama",
|
2023-09-09 11:12:10 +02:00
|
|
|
platforms: platforms,
|
2023-03-28 18:39:01 +02:00
|
|
|
products: [
|
|
|
|
.library(name: "llama", targets: ["llama"]),
|
|
|
|
],
|
|
|
|
targets: [
|
|
|
|
.target(
|
|
|
|
name: "llama",
|
|
|
|
path: ".",
|
2023-09-09 11:12:10 +02:00
|
|
|
exclude: exclude,
|
2023-09-03 08:21:05 +02:00
|
|
|
sources: [
|
|
|
|
"ggml.c",
|
|
|
|
"llama.cpp",
|
|
|
|
"ggml-alloc.c",
|
2023-09-09 11:12:10 +02:00
|
|
|
"k_quants.c",
|
|
|
|
] + additionalSources,
|
2023-03-28 18:39:01 +02:00
|
|
|
publicHeadersPath: "spm-headers",
|
2023-09-03 08:21:05 +02:00
|
|
|
cSettings: [
|
|
|
|
.unsafeFlags(["-Wno-shorten-64-to-32"]),
|
|
|
|
.define("GGML_USE_K_QUANTS"),
|
|
|
|
.define("GGML_USE_ACCELERATE")
|
2023-09-27 17:34:32 +02:00
|
|
|
.define("ACCELERATE_NEW_LAPACK")
|
|
|
|
.define("ACCELERATE_LAPACK_ILP64")
|
2023-09-09 11:12:10 +02:00
|
|
|
] + additionalSettings,
|
2023-04-05 12:44:24 +02:00
|
|
|
linkerSettings: [
|
|
|
|
.linkedFramework("Accelerate")
|
|
|
|
]
|
2023-09-09 11:12:10 +02:00
|
|
|
)
|
2023-03-28 18:39:01 +02:00
|
|
|
],
|
|
|
|
cxxLanguageStandard: .cxx11
|
|
|
|
)
|