@@ -194,6 +194,17 @@ pub fn build(b: *std.Build) !void {
194
194
.link_lib_cpp = false ,
195
195
.flags = cflags .items ,
196
196
});
197
+ const airCommand = b .addSystemCommand (&.{ "xcrun" , "-sdk" , "macosx" , "metal" , "-O3" , "-c" });
198
+ airCommand .addFileArg (.{ .path = "llama.cpp/ggml-metal.metal" });
199
+ airCommand .addArg ("-o" );
200
+ const air = airCommand .addOutputFileArg ("ggml-metal.air" );
201
+
202
+ const libCommand = b .addSystemCommand (&.{ "xcrun" , "-sdk" , "macosx" , "metallib" });
203
+ libCommand .addFileArg (air );
204
+ libCommand .addArg ("-o" );
205
+ const lib = libCommand .addOutputFileArg ("default.metallib" );
206
+ const libInstall = b .addInstallLibFile (lib , "default.metallib" );
207
+ b .getInstallStep ().dependOn (& libInstall .step );
197
208
try objs .append (ggml_metal );
198
209
} else {
199
210
const ggml_vulkan = buildObj (.{
@@ -229,8 +240,8 @@ pub fn build(b: *std.Build) !void {
229
240
extension .linkFramework ("MetalKit" );
230
241
extension .linkFramework ("Foundation" );
231
242
extension .linkFramework ("Accelerate" );
232
- b .installFile ("llama.cpp/ggml-metal.metal" , b .pathJoin (&.{ std .fs .path .basename (b .lib_dir ), "ggml-metal.metal" }));
233
- b .installFile ("llama.cpp/ggml-common.h" , b .pathJoin (&.{ std .fs .path .basename (b .lib_dir ), "ggml-common.h" }));
243
+ // b.installFile("llama.cpp/ggml-metal.metal", b.pathJoin(&.{ std.fs.path.basename(b.lib_dir), "ggml-metal.metal" }));
244
+ // b.installFile("llama.cpp/ggml-common.h", b.pathJoin(&.{ std.fs.path.basename(b.lib_dir), "ggml-common.h" }));
234
245
} else {
235
246
if (target .result .os .tag == .windows ) {
236
247
const vk_path = b .graph .env_map .get ("VK_SDK_PATH" ) orelse @panic ("VK_SDK_PATH not set" );
0 commit comments