@@ -4,6 +4,11 @@ import os from "node:os";
44import path from "node:path" ;
55import process from "node:process" ;
66
7+ interface NativeModule {
8+ name : string ;
9+ enabled ?: boolean ;
10+ }
11+
712const isRustAvailable = ( ) => {
813 try {
914 execSync ( "cargo --version" , { stdio : "ignore" } ) ;
@@ -32,39 +37,37 @@ if (!isRustAvailable()) {
3237 process . exit ( 1 ) ;
3338}
3439
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+ ] ;
3656
3757try {
38- console . log ( "[BuildNative] 开始构建原生模块..." ) ;
39-
4058 const args = process . argv . slice ( 2 ) ;
4159 const isDev = args . includes ( "--dev" ) ;
4260 const buildCommand = isDev ? "build:debug" : "build" ;
4361
44- execSync ( `pnpm --filter external-media-integration ${ buildCommand } ` , {
45- stdio : "inherit" ,
46- } ) ;
47-
48- console . log ( `[BuildNative] 构建 tools 原生模块 (${ buildCommand } )...` ) ;
49- execSync ( `pnpm --filter tools ${ buildCommand } ` , {
50- stdio : "inherit" ,
51- } ) ;
52-
53- if ( isWindows ) {
54- console . log ( `[BuildNative] 构建任务栏歌词原生模块 (${ buildCommand } )...` ) ;
55- execSync ( `pnpm --filter taskbar-lyric ${ buildCommand } ` , {
62+ for ( const mod of modules ) {
63+ if ( mod . enabled === false ) {
64+ continue ;
65+ }
66+ execSync ( `pnpm --filter ${ mod . name } ${ buildCommand } ` , {
5667 stdio : "inherit" ,
5768 } ) ;
5869 }
59-
60- // 有人抱怨编译 wasm 总是有问题,暂时注释掉
61- // console.log("[BuildNative] 构建 ferrous-opencc-wasm...");
62- // execSync("pnpm --filter ferrous-opencc-wasm build", {
63- // stdio: "inherit",
64- // });
6570} catch ( error ) {
6671 console . error ( "[BuildNative] 模块构建失败" , error ) ;
6772 process . exit ( 1 ) ;
6873}
69-
70- console . log ( "[BuildNative] 原生模块构建完成" ) ;
0 commit comments