Skip to content

Commit

Permalink
feat: only build cpu version in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
zcf0508 committed Feb 29, 2024
1 parent 6bfbce7 commit c53dbcf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"license": "MIT",
"private": true,
"scripts": {
"postinstall": "node ./script/post.js",
"dev": "vite",
"lint": "eslint --ext .ts --ext .vue ./src",
"format": "eslint --fix --ext .ts --ext .vue ./src",
Expand Down Expand Up @@ -46,6 +45,7 @@
"node-addon-api": "^5.1.0",
"release-it": "^15.6.0",
"shelljs": "^0.8.5",
"std-env": "^3.7.0",
"subtitle": "^4.2.1",
"typescript": "^4.9.3",
"unocss": "^0.46.5",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 24 additions & 22 deletions script/post.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const shelljs = require("shelljs")
const fs = require("node:fs")
const path = require("node:path")
const { isCI } = require("std-env")

function cpDirSync(source, target) {
const stat = fs.statSync(source)
Expand Down Expand Up @@ -68,28 +69,29 @@ if(
}
}

// 使用 fs 删除 build 文件夹
shelljs.rm("-rf", path.resolve(__dirname, "../lib/whisper.cpp/build"))

// gpu
shelljs.exec("cd ./lib/whisper.cpp && npx cmake-js compile --CDWHISPER_CUBLAS=1 -T whisper-addon -B Release")
if(
fs.existsSync(path.resolve(__dirname, "../lib/whisper.cpp/build/Release/whisper-addon.node"))
|| fs.existsSync(path.resolve(__dirname, "../lib/whisper.cpp/build/bin/Release/whisper-addon.node"))
) {
info("Copy whisper.cpp addon")
if(process.platform === "win32") {
cpDirSync(
path.resolve(__dirname, "../lib/whisper.cpp/build/bin/Release"),
path.resolve(__dirname, "../public/resources/cublas-whisper"),
)
} else {
cpDirSync(
path.resolve(__dirname, "../lib/whisper.cpp/build/Release"),
path.resolve(__dirname, "../public/resources/cublas-whisper"),
)
}
}
if(!isCI) {
// 使用 fs 删除 build 文件夹
shelljs.rm("-rf", path.resolve(__dirname, "../lib/whisper.cpp/build"))
// gpu
shelljs.exec("cd ./lib/whisper.cpp && npx cmake-js compile --CDWHISPER_CUBLAS=1 -T whisper-addon -B Release")
if(
fs.existsSync(path.resolve(__dirname, "../lib/whisper.cpp/build/Release/whisper-addon.node"))
|| fs.existsSync(path.resolve(__dirname, "../lib/whisper.cpp/build/bin/Release/whisper-addon.node"))
) {
info("Copy whisper.cpp addon")
if(process.platform === "win32") {
cpDirSync(
path.resolve(__dirname, "../lib/whisper.cpp/build/bin/Release"),
path.resolve(__dirname, "../public/resources/cublas-whisper"),
)
} else {
cpDirSync(
path.resolve(__dirname, "../lib/whisper.cpp/build/Release"),
path.resolve(__dirname, "../public/resources/cublas-whisper"),
)
}
}
}
}

if(!fs.existsSync(path.resolve(__dirname, "../lib/vad/CMakeLists.txt"))) {
Expand Down

0 comments on commit c53dbcf

Please sign in to comment.