refactor: build.bat flexible argument parsing, add run & help commands
- Replaced positional `%1` checks with a loop-based argument parser so flags (`test`, `clean`, `run`, `help`) work in any order/combination - Added `run` flag: executes `bin\WASURO.exe` after a successful build - Added `help` flag: prints usage info and exits - Fixed `clean` early-exit to also check `DO_RUN` (not just `TESTFLAGS`), so `build.bat clean run` correctly continues to build+run - Added section comment headers (Build, Run) for consistency
This commit is contained in:
1 parent
76d7d737c0
commit
ff65a0d5f0
1 file changed
+34
@@ -8,7 +8,34 @@ set LIB=%ROOT%lib
|
|||||||
set FPC=C:\Lazarus\fpc\3.2.2\bin\x86_64-win64\fpc.exe
|
set FPC=C:\Lazarus\fpc\3.2.2\bin\x86_64-win64\fpc.exe
|
||||||
|
|
||||||
set TESTFLAGS=
|
set TESTFLAGS=
|
||||||
|
set DO_CLEAN=0
|
||||||
|
set DO_RUN=0
|
||||||
|
|
||||||
|
:parse_args
|
||||||
|
if "%1"=="" goto args_done
|
||||||
if "%1"=="test" set TESTFLAGS=-dRUN_TESTS
|
if "%1"=="test" set TESTFLAGS=-dRUN_TESTS
|
||||||
|
if "%1"=="clean" set DO_CLEAN=1
|
||||||
|
if "%1"=="run" set DO_RUN=1
|
||||||
|
if "%1"=="help" (
|
||||||
|
echo Usage: build.bat [options]
|
||||||
|
echo Options:
|
||||||
|
echo test - Build with tests enabled
|
||||||
|
echo clean - Clean build outputs
|
||||||
|
echo run - Run the built executable after building
|
||||||
|
echo help - Show this help message
|
||||||
|
exit /b 0
|
||||||
|
)
|
||||||
|
shift
|
||||||
|
goto parse_args
|
||||||
|
:args_done
|
||||||
|
|
||||||
|
if %DO_CLEAN%==1 (
|
||||||
|
echo Cleaning build outputs...
|
||||||
|
if exist "%BIN%" rd /s /q "%BIN%"
|
||||||
|
if exist "%LIB%" rd /s /q "%LIB%"
|
||||||
|
echo Clean complete.
|
||||||
|
if "%TESTFLAGS%"=="" if %DO_RUN%==0 exit /b 0
|
||||||
|
)
|
||||||
|
|
||||||
if not exist "%BIN%" mkdir "%BIN%"
|
if not exist "%BIN%" mkdir "%BIN%"
|
||||||
if not exist "%LIB%" mkdir "%LIB%"
|
if not exist "%LIB%" mkdir "%LIB%"
|
||||||
@@ -17,6 +44,7 @@ REM ── Lint ─────────────────────
|
|||||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%ROOT%lint.ps1" -SrcRoot "%SRC%"
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%ROOT%lint.ps1" -SrcRoot "%SRC%"
|
||||||
if %ERRORLEVEL% NEQ 0 exit /b 1
|
if %ERRORLEVEL% NEQ 0 exit /b 1
|
||||||
|
|
||||||
|
REM ── Build ────────────────────────────────────────────────────────────
|
||||||
"%FPC%" ^
|
"%FPC%" ^
|
||||||
%TESTFLAGS% ^
|
%TESTFLAGS% ^
|
||||||
-FE"%BIN%" ^
|
-FE"%BIN%" ^
|
||||||
@@ -42,3 +70,9 @@ if %ERRORLEVEL% NEQ 0 (
|
|||||||
)
|
)
|
||||||
|
|
||||||
echo Build succeeded: %BIN%\WASURO.exe
|
echo Build succeeded: %BIN%\WASURO.exe
|
||||||
|
|
||||||
|
REM ── Run ────────────────────────────────────────────────────────────
|
||||||
|
if %DO_RUN%==1 (
|
||||||
|
echo Running WASURO...
|
||||||
|
"%BIN%\WASURO.exe"
|
||||||
|
)
|
||||||
Reference in new issue
Block a user