Repository navigation
Expand file tree
/
Copy pathBuild.bat
More file actions
574 lines (519 loc) · 18.9 KB
/
Copy pathBuild.bat
File metadata and controls
574 lines (519 loc) · 18.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
@echo off
setlocal EnableDelayedExpansion
pushd "%~dp0"
set "CONFIG=Release"
set "NO_PAUSE="
set "PLATFORM_TOOLSET=%PLATFORM_TOOLSET%"
set "PREMAKE_ACTION=vs2022"
:parse_args
if "%~1"=="" goto args_done
if /i "%~1"=="Debug" (
set "CONFIG=Debug"
shift
goto parse_args
)
if /i "%~1"=="Release" (
set "CONFIG=Release"
shift
goto parse_args
)
if /i "%~1"=="--no-pause" (
set "NO_PAUSE=1"
shift
goto parse_args
)
if /i "%~1"=="--toolset" goto parse_toolset
echo [Error] Unknown argument: %~1
echo Usage: Build.bat [Debug^|Release] [--toolset v145] [--no-pause]
goto fail
:parse_toolset
shift
if "%~1"=="" (
echo [Error] --toolset requires a value, e.g. v145 / v143
goto fail
)
set "TOOLSET_VALUE=%~1"
if /i "%TOOLSET_VALUE:~0,1%" NEQ "v" (
echo [Error] Invalid platform toolset: %TOOLSET_VALUE%
echo [Error] Expected a value such as v145 or v143.
goto fail
)
for /f "delims=0123456789" %%C in ("%TOOLSET_VALUE:~1%") do (
echo [Error] Invalid platform toolset: %TOOLSET_VALUE%
echo [Error] Expected a value such as v145 or v143.
goto fail
)
if "%TOOLSET_VALUE:~1%"=="" (
echo [Error] Invalid platform toolset: %TOOLSET_VALUE%
goto fail
)
set "PLATFORM_TOOLSET=%TOOLSET_VALUE%"
shift
goto parse_args
:args_done
echo ==========================================
echo XMenu Builder
echo ==========================================
echo Configuration: %CONFIG%
echo Platform: Win32
echo.
if not exist "tools\premake5.exe" (
echo [Error] tools\premake5.exe not found!
goto fail
)
call :resolve_toolchain
if errorlevel 1 goto fail
if not defined PLATFORM_TOOLSET set "PLATFORM_TOOLSET=!RESOLVED_TOOLSET!"
if not defined PLATFORM_TOOLSET set "PLATFORM_TOOLSET=v145"
call :validate_platform_toolset "!PLATFORM_TOOLSET!"
if errorlevel 1 goto fail
call :ensure_toolset_available "!PLATFORM_TOOLSET!"
if errorlevel 1 goto fail
echo [Info] Resolved PlatformToolset: !PLATFORM_TOOLSET!
echo [Info] Available PlatformToolsets: !AVAILABLE_TOOLSETS!
rem XMenu consumes the staged XBase Release SDK only.
if /i not "%CONFIG%"=="Release" (
echo [Error] Local XBase SDK currently contains Release libraries only.
echo [Error] Build XBase Debug and stage it separately before using Debug.
goto fail
)
for %%T in (XBaseModEntry XBaseSA XBaseVC XBaseIII PluginSA PluginVC PluginIII) do (
if not exist "lib\%%T.lib" (
echo [Error] Missing staged library: lib\%%T.lib
echo [Error] Run XBase Build.bat Release to rebuild the XBase SDK and stage plugin-sdk libraries.
goto fail
)
)
if not exist "include\XBase\XBase.h" (
echo [Error] Missing local XBase SDK headers: include\XBase\XBase.h
goto fail
)
if not exist "build" mkdir "build"
echo Using MSBuild: !MSBUILD_EXE!
if defined VS_INSTALL echo Using VS install: !VS_INSTALL!
if defined CL_EXE echo Using cl.exe: !CL_EXE!
echo Using PlatformToolset: !PLATFORM_TOOLSET!
if defined AVAILABLE_TOOLSETS echo Available toolsets: !AVAILABLE_TOOLSETS!
echo.
echo NOTE: Microsoft\VC\v180 is MSBuild targets path, NOT PlatformToolset.
echo On VS 18 the real C++ toolset is usually v145.
echo.
echo Removing stale generated project files...
del /Q "build\*.sln" "build\*.vcxproj" "build\*.vcxproj.filters" "build\*.vcxproj.user" >nul 2>nul
echo Generating Visual Studio project files (premake action: !PREMAKE_ACTION!)...
tools\premake5.exe !PREMAKE_ACTION!
if errorlevel 1 (
echo [Error] Project generation failed.
goto fail
)
if not exist "build\XMenu.sln" (
echo [Error] build\XMenu.sln not found after generation.
goto fail
)
call :validate_xbase_sdk_boundary
if errorlevel 1 goto fail
rem Prefer MSBuild property override. File rewrite is optional (IDE convenience only)
rem and must never corrupt premake UTF-8 output.
call :apply_platform_toolset
if errorlevel 1 (
echo [Warning] Could not rewrite vcxproj toolset; continuing with MSBuild /p:PlatformToolset.
) else (
echo [Info] PlatformToolset rewritten to !PLATFORM_TOOLSET! in build\*.vcxproj
)
set "MSBUILD_PROPS=/p:Configuration=%CONFIG% /p:Platform=Win32 /p:PlatformToolset=!PLATFORM_TOOLSET! /verbosity:minimal"
echo Building mod asi build\bin\XMenuSA.asi...
"!MSBUILD_EXE!" "build\XMenu.sln" /m /t:XMenuSA !MSBUILD_PROPS!
if errorlevel 1 (
echo.
echo [Error] XMenuSA asi build failed.
goto fail
)
echo Building mod asi build\bin\XMenuVC.asi...
"!MSBUILD_EXE!" "build\XMenu.sln" /m /t:XMenuVC !MSBUILD_PROPS!
if errorlevel 1 (
echo.
echo [Error] XMenuVC asi build failed.
goto fail
)
echo Building mod asi build\bin\XMenuIII.asi...
"!MSBUILD_EXE!" "build\XMenu.sln" /m /t:XMenuIII !MSBUILD_PROPS!
if errorlevel 1 (
echo.
echo [Error] XMenuIII asi build failed.
goto fail
)
echo Building installer build\bin\XMenuInstaller.exe...
"!MSBUILD_EXE!" "build\XMenu.sln" /m /t:XMenuInstaller !MSBUILD_PROPS!
if errorlevel 1 (
echo.
echo [Error] Installer build failed.
goto fail
)
if not exist "build\bin\XMenuSA.asi" (
echo [Error] build\bin\XMenuSA.asi was not produced.
goto fail
)
if not exist "build\bin\XMenuVC.asi" (
echo [Error] build\bin\XMenuVC.asi was not produced.
goto fail
)
if not exist "build\bin\XMenuIII.asi" (
echo [Error] build\bin\XMenuIII.asi was not produced.
goto fail
)
if not exist "build\bin\XMenuInstaller.exe" (
echo [Error] build\bin\XMenuInstaller.exe was not produced.
goto fail
)
call :stage_data
if errorlevel 1 goto fail
rem 共享运行时与 mod 是配套的(ABI 版本一起升),构建时一并暂存到安装集,
rem 否则发布包里的旧运行库会让 mod 报「ABI 版本不符」
set "XBASE_RUNTIME_DIR=..\XBase\build\bin\Release\XBase\Library"
if not exist "!XBASE_RUNTIME_DIR!\XBaseSA.dll" (
echo [Error] Missing XBase shared runtime: !XBASE_RUNTIME_DIR!\XBaseSA.dll
echo Build the XBase project first, then build XMenu.
goto fail
)
if not exist "build\bin\XBase\Library" mkdir "build\bin\XBase\Library"
for %%D in (SA VC III) do (
copy /Y "!XBASE_RUNTIME_DIR!\XBase%%D.dll" "build\bin\XBase\Library\XBase%%D.dll" >nul
if errorlevel 1 (
echo [Error] Failed to stage XBase%%D.dll
goto fail
)
)
if exist "lib\WebView2Loader.dll" (
copy /Y "lib\WebView2Loader.dll" "build\bin\XBase\Library\WebView2Loader.dll" >nul
if errorlevel 1 (
echo [Error] Failed to stage WebView2Loader.dll
goto fail
)
) else (
echo [Warning] Staged XBase SDK has no WebView2Loader.dll; WebUI installation may be unavailable.
)
rem 通用面板随 XBase 一起分发,各模组挂进来就行,不必自带前端
set "XBASE_PANEL_DIR=..\XBase\build\bin\Release\XBase\Library\panel"
if exist "!XBASE_PANEL_DIR!\index.html" (
if not exist "build\bin\XBase\Library\panel" mkdir "build\bin\XBase\Library\panel"
xcopy "!XBASE_PANEL_DIR!\*" "build\bin\XBase\Library\panel\" /E /I /Y >nul
if errorlevel 1 (
echo [Error] Failed to stage the XBase panel
goto fail
)
echo [Info] Staged XBase panel to build\bin\XBase\Library\panel
) else (
echo [Warning] XBase panel not found at !XBASE_PANEL_DIR!; build it with npm run build inside XBase\panel.
)
echo.
echo Build completed successfully.
echo Output files:
echo build\bin\XMenuSA.asi
echo build\bin\XMenuVC.asi
echo build\bin\XMenuIII.asi
echo build\bin\XMenuInstaller.exe
echo build\bin\XBase\Library\XBase{SA,VC,III}.dll
echo build\bin\XBase\Library\panel\index.html
echo build\bin\XBase\Mods\XMenu\data\{sa,vc,iii}\*.json
echo build\bin\XBase\Mods\XMenu\data\i18n\{lang}\index.json
echo.
goto success
rem ============================================================
rem Generated projects must consume only the staged XBase SDK.
rem ============================================================
:validate_xbase_sdk_boundary
for %%P in (XMenuSA XMenuVC XMenuIII XMenuInstaller) do (
if not exist "build\%%P.vcxproj" (
echo [Error] Missing generated project: build\%%P.vcxproj
exit /b 1
)
)
rem Any generated target crossing into XBase sources or legacy SDKs is invalid.
findstr /S /I /M /C:"..\XBase" /C:"../XBase" /C:"PayloadEntry.cpp" /C:"BootstrapEntry.cpp" /C:"plugin-sdk" /C:"plugin.h" /C:"plugin_sa" /C:"plugin_vc" /C:"plugin_III" /C:"PSDK_DIR" /C:"PLUGIN_SDK_DIR" /C:"imgui" /C:"kiero" /C:"MinHook" /C:"MH_" "build\*.vcxproj" "build\*.sln" >nul 2>nul
if not errorlevel 1 (
echo [Error] Generated projects crossed the staged XBase SDK boundary.
exit /b 1
)
rem Installer owns its platform dependencies; mod asis must not.
findstr /I /M /C:"d3d9" /C:"Direct3D" /C:"urlmon.lib" /C:"Pdh.lib" /C:"shell32.lib" /C:"ole32.lib" "build\XMenuSA.vcxproj" "build\XMenuVC.vcxproj" "build\XMenuIII.vcxproj" >nul 2>nul
if not errorlevel 1 (
echo [Error] Generated mod asi projects still link platform or renderer libraries directly.
exit /b 1
)
for %%G in (SA VC III) do (
findstr /I /C:"XBaseModEntry.lib" "build\XMenu%%G.vcxproj" >nul 2>nul
if errorlevel 1 (
echo [Error] Mod project %%G does not link XBaseModEntry.lib.
exit /b 1
)
findstr /I /C:"/WHOLEARCHIVE:XBaseModEntry.lib" "build\XMenu%%G.vcxproj" >nul 2>nul
if errorlevel 1 (
echo [Error] Mod project %%G does not retain the XBase mod entry object.
exit /b 1
)
findstr /I /C:"XBase%%G.lib" "build\XMenu%%G.vcxproj" >nul 2>nul
if errorlevel 1 (
echo [Error] Mod project %%G does not link XBase%%G.lib.
exit /b 1
)
)
exit /b 0
rem ============================================================
rem Pure-cmd toolchain resolve (no PowerShell).
rem PlatformToolset = folders under Platforms\Win32\PlatformToolsets
rem NOT the Microsoft\VC\v180 targets folder name.
rem ============================================================
:resolve_toolchain
set "MSBUILD_EXE="
set "VS_INSTALL="
set "CL_EXE="
set "RESOLVED_TOOLSET="
set "AVAILABLE_TOOLSETS="
rem 1) Developer Command Prompt already set VSINSTALLDIR
if defined VSINSTALLDIR (
if exist "%VSINSTALLDIR%MSBuild\Current\Bin\MSBuild.exe" (
set "MSBUILD_EXE=%VSINSTALLDIR%MSBuild\Current\Bin\MSBuild.exe"
set "VS_INSTALL=%VSINSTALLDIR%"
if "!VS_INSTALL:~-1!"=="\" set "VS_INSTALL=!VS_INSTALL:~0,-1!"
)
)
rem 2) vswhere (optional)
if not defined MSBUILD_EXE (
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if exist "!VSWHERE!" (
for /f "usebackq delims=" %%i in (`"!VSWHERE!" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe 2^>nul`) do (
if not defined MSBUILD_EXE set "MSBUILD_EXE=%%i"
)
)
)
rem 3) Hardcoded common roots (includes custom D:\SoftWare install)
if not defined MSBUILD_EXE (
for %%R in (
"D:\SoftWare\Microsoft Visual Studio"
"%ProgramFiles%\Microsoft Visual Studio"
"%ProgramFiles(x86)%\Microsoft Visual Studio"
) do (
if not defined MSBUILD_EXE if exist "%%~R\" (
for %%Y in (18 2026 2025 2022 2019) do (
if not defined MSBUILD_EXE (
for %%E in (Community Professional Enterprise BuildTools Preview) do (
if not defined MSBUILD_EXE if exist "%%~R\%%Y\%%E\MSBuild\Current\Bin\MSBuild.exe" (
set "MSBUILD_EXE=%%~R\%%Y\%%E\MSBuild\Current\Bin\MSBuild.exe"
set "VS_INSTALL=%%~R\%%Y\%%E"
)
)
)
)
)
)
)
rem 4) PATH fallback
if not defined MSBUILD_EXE (
for /f "delims=" %%i in ('where MSBuild.exe 2^>nul') do (
if not defined MSBUILD_EXE set "MSBUILD_EXE=%%i"
)
)
if not defined MSBUILD_EXE (
echo [Error] MSBuild.exe not found.
echo Install Visual Studio with "Desktop development with C++".
exit /b 1
)
rem Derive VS install from MSBuild path: ...\MSBuild\Current\Bin\MSBuild.exe
if not defined VS_INSTALL (
for %%I in ("!MSBUILD_EXE!") do set "MSBUILD_BIN=%%~dpI"
rem Bin\ -> Current\ -> MSBuild\ -> VS root
for %%I in ("!MSBUILD_BIN!\..\..\..") do set "VS_INSTALL=%%~fI"
)
rem Find cl.exe under VC\Tools\MSVC
if defined VS_INSTALL (
for /f "delims=" %%D in ('dir /b /ad /o-n "!VS_INSTALL!\VC\Tools\MSVC" 2^>nul') do (
if not defined CL_EXE (
if exist "!VS_INSTALL!\VC\Tools\MSVC\%%D\bin\Hostx86\x86\cl.exe" (
set "CL_EXE=!VS_INSTALL!\VC\Tools\MSVC\%%D\bin\Hostx86\x86\cl.exe"
) else if exist "!VS_INSTALL!\VC\Tools\MSVC\%%D\bin\HostX86\x86\cl.exe" (
set "CL_EXE=!VS_INSTALL!\VC\Tools\MSVC\%%D\bin\HostX86\x86\cl.exe"
) else if exist "!VS_INSTALL!\VC\Tools\MSVC\%%D\bin\Hostx64\x86\cl.exe" (
set "CL_EXE=!VS_INSTALL!\VC\Tools\MSVC\%%D\bin\Hostx64\x86\cl.exe"
)
)
)
)
if not defined CL_EXE (
echo [Error] cl.exe not found under: !VS_INSTALL!\VC\Tools\MSVC
echo Open VS Installer -^> Modify -^> enable "Desktop development with C++" / MSVC x86/x64 build tools.
exit /b 1
)
rem Collect real PlatformToolsets (prefer highest known id)
set "HAS_V145="
set "HAS_V143="
set "HAS_V142="
set "HAS_V141="
if defined VS_INSTALL (
for /d %%V in ("!VS_INSTALL!\MSBuild\Microsoft\VC\v*") do (
for /d %%T in ("%%~fV\Platforms\Win32\PlatformToolsets\v*") do (
if exist "%%~fT\Toolset.props" (
set "TS=%%~nxT"
set "TOOLSET_AVAILABLE_!TS!=1"
if /i "!TS!"=="v145" set "HAS_V145=1"
if /i "!TS!"=="v143" set "HAS_V143=1"
if /i "!TS!"=="v142" set "HAS_V142=1"
if /i "!TS!"=="v141" set "HAS_V141=1"
if defined AVAILABLE_TOOLSETS (
set "AVAILABLE_TOOLSETS=!AVAILABLE_TOOLSETS!,!TS!"
) else (
set "AVAILABLE_TOOLSETS=!TS!"
)
)
)
)
)
if defined HAS_V145 (
set "RESOLVED_TOOLSET=v145"
) else if defined HAS_V143 (
set "RESOLVED_TOOLSET=v143"
) else if defined HAS_V142 (
set "RESOLVED_TOOLSET=v142"
) else if defined HAS_V141 (
set "RESOLVED_TOOLSET=v141"
) else (
rem Last resort: VS18 defaults to v145 even if folder scan failed
set "RESOLVED_TOOLSET=v145"
)
if not defined AVAILABLE_TOOLSETS set "AVAILABLE_TOOLSETS=!RESOLVED_TOOLSET!"
exit /b 0
:validate_platform_toolset
set "VALIDATED_TOOLSET=%~1"
if "!VALIDATED_TOOLSET!"=="" (
echo [Error] PlatformToolset is empty.
exit /b 1
)
if /i "!VALIDATED_TOOLSET:~0,1!" NEQ "v" (
echo [Error] Invalid PlatformToolset: !VALIDATED_TOOLSET!
echo [Error] Expected a value such as v145 or v143.
exit /b 1
)
for /f "delims=0123456789" %%C in ("!VALIDATED_TOOLSET:~1!") do (
echo [Error] Invalid PlatformToolset: !VALIDATED_TOOLSET!
echo [Error] Expected a value such as v145 or v143.
exit /b 1
)
if "!VALIDATED_TOOLSET:~1!"=="" (
echo [Error] Invalid PlatformToolset: !VALIDATED_TOOLSET!
exit /b 1
)
exit /b 0
:ensure_toolset_available
set "REQUESTED_TOOLSET=%~1"
call set "TOOLSET_FOUND=%%TOOLSET_AVAILABLE_%REQUESTED_TOOLSET%%%"
if not defined TOOLSET_FOUND (
echo [Error] PlatformToolset !REQUESTED_TOOLSET! is not installed for Win32.
echo [Error] Available toolsets: !AVAILABLE_TOOLSETS!
exit /b 1
)
exit /b 0
rem ============================================================
rem Rewrite PlatformToolset in vcxproj without PowerShell.
rem ============================================================
:apply_platform_toolset
if not defined PLATFORM_TOOLSET exit /b 1
if not exist "build\*.vcxproj" (
echo [Error] No vcxproj found under build\
exit /b 1
)
if not exist "tools\apply_platform_toolset.vbs" (
echo [Error] tools\apply_platform_toolset.vbs missing
exit /b 1
)
cscript //nologo "tools\apply_platform_toolset.vbs" "!PLATFORM_TOOLSET!" "build"
if errorlevel 1 (
echo [Error] Failed to rewrite PlatformToolset via cscript.
exit /b 1
)
exit /b 0
:stage_data
if exist "tools\build_i18n_split.py" (
py -3 "tools\build_i18n_split.py" >nul 2>nul
if errorlevel 1 python "tools\build_i18n_split.py" >nul 2>nul
)
if exist "tools\generate_scene_visual_data.py" (
py -3 "tools\generate_scene_visual_data.py" >nul 2>nul
if errorlevel 1 python "tools\generate_scene_visual_data.py" >nul 2>nul
)
if exist "build\bin\XBase\Mods\XMenu\data" rmdir /S /Q "build\bin\XBase\Mods\XMenu\data"
if exist "build\bin\XBase\Mods\XMenu\i18n" rmdir /S /Q "build\bin\XBase\Mods\XMenu\i18n"
if not exist "build\bin\XBase\Mods\XMenu" mkdir "build\bin\XBase\Mods\XMenu"
if not exist "build\bin\XBase\Mods\XMenu\data" mkdir "build\bin\XBase\Mods\XMenu\data"
for %%G in (sa vc iii) do (
if not exist "src\data\%%G" (
echo [Error] Missing data directory: src\data\%%G
exit /b 1
)
xcopy "src\data\%%G" "build\bin\XBase\Mods\XMenu\data\%%G\" /E /I /Y >nul
if errorlevel 1 (
echo [Error] Failed to stage data pack: %%G
exit /b 1
)
)
if not exist "build\bin\XBase\Mods\XMenu\data\i18n" mkdir "build\bin\XBase\Mods\XMenu\data\i18n"
for %%L in (zh en jp ru) do (
if not exist "src\data\i18n\%%L\index.json" (
echo [Error] Missing language index: src\data\i18n\%%L\index.json
exit /b 1
)
xcopy "src\data\i18n\%%L" "build\bin\XBase\Mods\XMenu\data\i18n\%%L\" /E /I /Y >nul
if errorlevel 1 (
echo [Error] Failed to stage data language pack: %%L
exit /b 1
)
)
rem 界面特性注册表,网页界面与宿主界面共用同一份 schema,控件与能力门控都从这里取
if not exist "src\data\ui-schema.json" (
echo [Error] Missing UI schema: src\data\ui-schema.json
exit /b 1
)
copy /Y "src\data\ui-schema.json" "build\bin\XBase\Mods\XMenu\data\ui-schema.json" >nul
if errorlevel 1 (
echo [Error] Failed to stage UI schema
exit /b 1
)
rem mod 清单,声明 mod 自身版本与所需 XBase 版本,XBase 挂载时校验
if not exist "src\data\package.json" (
echo [Error] Missing package manifest: src\data\package.json
exit /b 1
)
copy /Y "src\data\package.json" "build\bin\XBase\Mods\XMenu\package.json" >nul
if errorlevel 1 (
echo [Error] Failed to stage package manifest
exit /b 1
)
if exist "react\dist\ui.html" (
if exist "build\bin\XBase\Mods\XMenu\ui" rmdir /S /Q "build\bin\XBase\Mods\XMenu\ui"
rem 脚本与样式放在 data 目录,ui.html 只用相对路径引用,file 协议下经典脚本不受 CORS 限制
copy /Y "react\dist\ui.html" "build\bin\XBase\Mods\XMenu\ui.html" >nul
if exist "react\dist\data" (
xcopy "react\dist\data" "build\bin\XBase\Mods\XMenu\data\" /E /I /Y >nul
if errorlevel 1 (
echo [Error] Failed to stage React UI assets.
exit /b 1
)
)
if not exist "build\bin\XBase\Mods\XMenu\ui.html" (
echo [Error] Failed to stage React UI bundle.
exit /b 1
)
if not exist "build\bin\XBase\Mods\XMenu\data\app.js" (
echo [Error] Failed to stage React UI scripts.
exit /b 1
)
) else (
echo [Warning] react\dist not found; run pnpm build in react before packaging.
)
exit /b 0
:success
popd
if not defined NO_PAUSE pause
exit /b 0
:fail
popd
if not defined NO_PAUSE pause
exit /b 1