diff --git a/Package.swift b/Package.swift index 7626d7a..d878088 100644 --- a/Package.swift +++ b/Package.swift @@ -14,15 +14,47 @@ let package = Package( .library(name: "SwiftWhisper", targets: ["SwiftWhisper"]) ], targets: [ - .target(name: "SwiftWhisper", dependencies: [.target(name: "whisper_cpp")]), - .target(name: "whisper_cpp", - exclude: exclude, - cSettings: [ - .define("GGML_USE_ACCELERATE", .when(platforms: [.macOS, .macCatalyst, .iOS])), - .define("WHISPER_USE_COREML", .when(platforms: [.macOS, .macCatalyst, .iOS])), - .define("WHISPER_COREML_ALLOW_FALLBACK", .when(platforms: [.macOS, .macCatalyst, .iOS])) - ]), - .testTarget(name: "WhisperTests", dependencies: [.target(name: "SwiftWhisper")], resources: [.copy("TestResources/")]) + .target( + name: "SwiftWhisper", + dependencies: ["whisper_cpp", "whisper_cpp_metal"] + ), + .target( + name: "whisper_cpp_metal", + path: "Sources/whisper_cpp_metal", + sources: ["ggml-metal.m"], + publicHeadersPath: "include", + cSettings: [ + .unsafeFlags(["-fno-objc-arc"]) + ] + ), + .target( + name: "whisper_cpp", + dependencies: [.target(name: "whisper_cpp_metal")], + path: "Sources/whisper_cpp", + sources: [ + "ggml.c", + "ggml-alloc.c", + "coreml/whisper-encoder-impl.m", + "coreml/whisper-encoder.mm", + "whisper.cpp", + ], + publicHeadersPath: "include", + cSettings: [ + .unsafeFlags(["-Wno-shorten-64-to-32"]), + .define("GGML_USE_ACCELERATE", .when(platforms: [.macOS, .macCatalyst, .iOS])), + .define("WHISPER_USE_COREML", .when(platforms: [.macOS, .macCatalyst, .iOS])), + .define("WHISPER_COREML_ALLOW_FALLBACK", .when(platforms: [.macOS, .macCatalyst, .iOS])), + .define("GGML_USE_METAL", .when(platforms: [.macOS, .macCatalyst, .iOS])) + ], + linkerSettings: [ + .linkedFramework("Accelerate"), + ] + ), + .testTarget( + name: "WhisperTests", + dependencies: ["SwiftWhisper"], + resources: [.copy("TestResources/")] + ) ], cxxLanguageStandard: CXXLanguageStandard.cxx11 ) diff --git a/Sources/whisper_cpp/ggml-alloc.c b/Sources/whisper_cpp/ggml-alloc.c new file mode 120000 index 0000000..66cf21d --- /dev/null +++ b/Sources/whisper_cpp/ggml-alloc.c @@ -0,0 +1 @@ +../../whisper.cpp/ggml-alloc.c \ No newline at end of file diff --git a/Sources/whisper_cpp/ggml-alloc.h b/Sources/whisper_cpp/ggml-alloc.h new file mode 120000 index 0000000..971fb43 --- /dev/null +++ b/Sources/whisper_cpp/ggml-alloc.h @@ -0,0 +1 @@ +../../whisper.cpp/ggml-alloc.h \ No newline at end of file diff --git a/Sources/whisper_cpp/ggml-metal.h b/Sources/whisper_cpp/ggml-metal.h new file mode 120000 index 0000000..d00bdb6 --- /dev/null +++ b/Sources/whisper_cpp/ggml-metal.h @@ -0,0 +1 @@ +../whisper_cpp_metal/ggml-metal.h \ No newline at end of file diff --git a/Sources/whisper_cpp_metal/ggml-alloc.h b/Sources/whisper_cpp_metal/ggml-alloc.h new file mode 120000 index 0000000..13216cf --- /dev/null +++ b/Sources/whisper_cpp_metal/ggml-alloc.h @@ -0,0 +1 @@ +../whisper_cpp/ggml-alloc.h \ No newline at end of file diff --git a/Sources/whisper_cpp_metal/ggml-metal.h b/Sources/whisper_cpp_metal/ggml-metal.h new file mode 120000 index 0000000..6c5d541 --- /dev/null +++ b/Sources/whisper_cpp_metal/ggml-metal.h @@ -0,0 +1 @@ +../../whisper.cpp/ggml-metal.h \ No newline at end of file diff --git a/Sources/whisper_cpp_metal/ggml-metal.m b/Sources/whisper_cpp_metal/ggml-metal.m new file mode 120000 index 0000000..0b08eee --- /dev/null +++ b/Sources/whisper_cpp_metal/ggml-metal.m @@ -0,0 +1 @@ +../../whisper.cpp/ggml-metal.m \ No newline at end of file diff --git a/Sources/whisper_cpp_metal/ggml.h b/Sources/whisper_cpp_metal/ggml.h new file mode 120000 index 0000000..57eb840 --- /dev/null +++ b/Sources/whisper_cpp_metal/ggml.h @@ -0,0 +1 @@ +../whisper_cpp/ggml.h \ No newline at end of file diff --git a/Sources/whisper_cpp_metal/include/whisper.h b/Sources/whisper_cpp_metal/include/whisper.h new file mode 120000 index 0000000..5769596 --- /dev/null +++ b/Sources/whisper_cpp_metal/include/whisper.h @@ -0,0 +1 @@ +../../whisper_cpp/include/whisper.h \ No newline at end of file diff --git a/whisper.cpp b/whisper.cpp index 95b02d7..54c978c 160000 --- a/whisper.cpp +++ b/whisper.cpp @@ -1 +1 @@ -Subproject commit 95b02d76b04d18e4ce37ed8353a1f0797f1717ea +Subproject commit 54c978c3a31dac51bb6fab06d5ac5b11b336ae30