Skip to content

Commit 333dec5

Browse files
committed
build: embed ggml-common.h into ggml-metal.metal
1 parent 69c81ab commit 333dec5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/binding.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
process.env.GGML_METAL_PATH_RESOURCES =
2-
process.env.GGML_METAL_PATH_RESOURCES || path.join(__dirname, "../whisper.cpp");
2+
process.env.GGML_METAL_PATH_RESOURCES || path.join(__dirname, "../whisper.cpp/ggml/src");
33

44
import path from "node:path";
55
import { TranscribeFormat, TranscribeParams, TranscribeResult } from "./types";

tsup.config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import { defineConfig } from "tsup";
2+
import { readFileSync, writeFileSync } from "node:fs";
23

34
export default defineConfig({
45
entry: ["src/index.ts", "src/build.ts"],
56
outDir: "dist",
67
dts: true,
8+
async onSuccess() {
9+
// replace `#include "ggml-common.h" in whisper.cpp/ggml/src/ggml-metal.metal with full content
10+
const metal = readFileSync("whisper.cpp/ggml/src/ggml-metal.metal", "utf-8");
11+
const common = readFileSync("whisper.cpp/ggml/src/ggml-common.h", "utf-8");
12+
const replaced = metal.replace(/#include "ggml-common.h"/, common);
13+
writeFileSync("whisper.cpp/ggml/src/ggml-metal.metal", replaced);
14+
},
715
});

0 commit comments

Comments
 (0)