metal : use SWIFT_PACKAGE def instead of define GGML_SWIFT

This commit is contained in:
Jhen 2023-10-07 11:20:11 +08:00
parent 1b88cbadd5
commit f134d64bbd
3 changed files with 6 additions and 6 deletions

1
.gitignore vendored
View file

@ -10,6 +10,7 @@
*.gcno
*.gcda
*.dot
*.metallib
.DS_Store
.build/
.cache/

View file

@ -16,13 +16,12 @@ let resources: [Resource] = [
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 resources: [String] = []
let resources: [Resource] = []
let additionalSources: [String] = []
let additionalSettings: [CSetting] = []
#endif

View file

@ -186,7 +186,7 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) {
// load library
{
NSBundle * bundle = nil;
#ifdef GGML_SWIFT
#ifdef SWIFT_PACKAGE
bundle = SWIFTPM_MODULE_BUNDLE;
#else
bundle = [NSBundle bundleForClass:[GGMLMetalClass class]];
@ -204,7 +204,7 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) {
GGML_METAL_LOG_INFO("%s: loading '%s'\n", __func__, [sourcePath UTF8String]);
NSString * src = [NSString stringWithContentsOfFile:sourcePath encoding:NSUTF8StringEncoding error:&error];
if (error) {
GGML_METAL_LOG_INFO("%s: error: %s\n", __func__, [[error description] UTF8String]);
GGML_METAL_LOG_ERROR("%s: error: %s\n", __func__, [[error description] UTF8String]);
return NULL;
}
@ -217,7 +217,7 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) {
}
if (error) {
GGML_METAL_LOG_INFO("%s: error: %s\n", __func__, [[error description] UTF8String]);
GGML_METAL_LOG_ERROR("%s: error: %s\n", __func__, [[error description] UTF8String]);
return NULL;
}
}