|
| 1 | +import dotenv from "dotenv"; |
1 | 2 | import { execSync } from "node:child_process"; |
2 | 3 | import os from "node:os"; |
3 | | -import process from "node:process"; |
4 | | -import dotenv from "dotenv"; |
5 | 4 | import path from "node:path"; |
| 5 | +import process from "node:process"; |
| 6 | + |
| 7 | +interface NativeModule { |
| 8 | + name: string; |
| 9 | + enabled?: boolean; |
| 10 | +} |
6 | 11 |
|
7 | 12 | const isRustAvailable = () => { |
8 | 13 | try { |
@@ -32,35 +37,37 @@ if (!isRustAvailable()) { |
32 | 37 | process.exit(1); |
33 | 38 | } |
34 | 39 |
|
35 | | -console.log(`[BuildNative] 当前构建目标: ${process.platform}`); |
| 40 | +const modules: NativeModule[] = [ |
| 41 | + { |
| 42 | + name: "external-media-integration", |
| 43 | + }, |
| 44 | + { |
| 45 | + name: "tools", |
| 46 | + }, |
| 47 | + { |
| 48 | + name: "taskbar-lyric", |
| 49 | + enabled: isWindows, |
| 50 | + }, |
| 51 | + // 有人抱怨编译 wasm 总是有问题,暂时注释掉 |
| 52 | + // { |
| 53 | + // name: "ferrous-opencc-wasm", |
| 54 | + // }, |
| 55 | +]; |
36 | 56 |
|
37 | 57 | try { |
38 | | - console.log("[BuildNative] 开始构建原生模块..."); |
39 | | - |
40 | | - execSync("pnpm --filter external-media-integration build", { |
41 | | - stdio: "inherit", |
42 | | - }); |
43 | | - |
44 | | - console.log("[BuildNative] 构建 tools 原生模块..."); |
45 | | - execSync("pnpm --filter tools build", { |
46 | | - stdio: "inherit", |
47 | | - }); |
| 58 | + const args = process.argv.slice(2); |
| 59 | + const isDev = args.includes("--dev"); |
| 60 | + const buildCommand = isDev ? "build:debug" : "build"; |
48 | 61 |
|
49 | | - if (isWindows) { |
50 | | - console.log("[BuildNative] 构建任务栏歌词原生模块..."); |
51 | | - execSync("pnpm --filter taskbar-lyric build", { |
| 62 | + for (const mod of modules) { |
| 63 | + if (mod.enabled === false) { |
| 64 | + continue; |
| 65 | + } |
| 66 | + execSync(`pnpm --filter ${mod.name} ${buildCommand}`, { |
52 | 67 | stdio: "inherit", |
53 | 68 | }); |
54 | 69 | } |
55 | | - |
56 | | - // 有人抱怨编译 wasm 总是有问题,暂时注释掉 |
57 | | - // console.log("[BuildNative] 构建 ferrous-opencc-wasm..."); |
58 | | - // execSync("pnpm --filter ferrous-opencc-wasm build", { |
59 | | - // stdio: "inherit", |
60 | | - // }); |
61 | 70 | } catch (error) { |
62 | 71 | console.error("[BuildNative] 模块构建失败", error); |
63 | 72 | process.exit(1); |
64 | 73 | } |
65 | | - |
66 | | -console.log("[BuildNative] 原生模块构建完成"); |
|
0 commit comments