build: 加 rebuild 命令(--clean-first 强制全量重编+启动),规避 ninja 增量偶发漏编

This commit is contained in:
gaozheng 2026-06-16 09:38:07 +08:00
parent 87b90a2022
commit a5e4f04bd9
1 changed files with 16 additions and 5 deletions

View File

@ -2,11 +2,13 @@
REM ============================================================ REM ============================================================
REM geopro build helper (Windows / MSVC + Ninja, CMake presets) REM geopro build helper (Windows / MSVC + Ninja, CMake presets)
REM REM
REM Usage: build [app | all | test | run | configure] REM Usage: build [app | all | test | run | rebuild | configure]
REM app (default) build target geopro_desktop REM app (default) build target geopro_desktop (incremental)
REM all build all targets REM all build all targets (incremental)
REM test build + run unit tests via ctest REM test build + run unit tests via ctest
REM run build + launch geopro_desktop REM run incremental build + launch geopro_desktop
REM rebuild FORCE clean rebuild (--clean-first) + launch — use when
REM incremental seems stale / changes not showing up
REM configure force re-run CMake configure (after CMakeLists changes) REM configure force re-run CMake configure (after CMakeLists changes)
REM REM
REM Requires: Visual Studio 2022/2026 (Desktop C++ workload, ships REM Requires: Visual Studio 2022/2026 (Desktop C++ workload, ships
@ -48,7 +50,8 @@ if /i "%CMD%"=="app" goto :app
if /i "%CMD%"=="all" goto :all if /i "%CMD%"=="all" goto :all
if /i "%CMD%"=="test" goto :test if /i "%CMD%"=="test" goto :test
if /i "%CMD%"=="run" goto :run if /i "%CMD%"=="run" goto :run
echo [build] unknown command "%CMD%". Use: app ^| all ^| test ^| run ^| configure if /i "%CMD%"=="rebuild" goto :rebuild
echo [build] unknown command "%CMD%". Use: app ^| all ^| test ^| run ^| rebuild ^| configure
exit /b 1 exit /b 1
:ensure :ensure
@ -80,3 +83,11 @@ call :ensure
"%CMAKE%" --build "%BUILDDIR%" --target geopro_desktop || exit /b 1 "%CMAKE%" --build "%BUILDDIR%" --target geopro_desktop || exit /b 1
"%BUILDDIR%\src\app\geopro_desktop.exe" "%BUILDDIR%\src\app\geopro_desktop.exe"
exit /b %errorlevel% exit /b %errorlevel%
:rebuild
REM 强制全量重编(--clean-first 先清后编),规避 ninja 增量偶发漏编;编后启动。
REM 注意:若 geopro_desktop 正在运行,链接会因 exe 被占用失败(LNK1104)——先关掉 app。
call :ensure
"%CMAKE%" --build "%BUILDDIR%" --target geopro_desktop --clean-first || exit /b 1
"%BUILDDIR%\src\app\geopro_desktop.exe"
exit /b %errorlevel%