59 lines
2.8 KiB
Batchfile
59 lines
2.8 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
rem ──────────────────────────────────────────────────
|
|
rem Defaults (override by passing [backend] [build])
|
|
rem ──────────────────────────────────────────────────
|
|
set BUILD_DIR=builddir
|
|
set BACKEND=vs2022
|
|
set BUILD=debug
|
|
|
|
rem ──────────────────────────────────────────────────
|
|
rem Recognize help flags
|
|
rem ──────────────────────────────────────────────────
|
|
if /I "%~1"=="-?" goto usage
|
|
if /I "%~1"=="/?" goto usage
|
|
if /I "%~1"=="-h" goto usage
|
|
if /I "%~1"=="--help" goto usage
|
|
|
|
rem ──────────────────────────────────────────────────
|
|
rem Parse positional arguments
|
|
rem ──────────────────────────────────────────────────
|
|
if not "%~1"=="" set BACKEND=%~1
|
|
if not "%~2"=="" set BUILD=%~2
|
|
|
|
rem ──────────────────────────────────────────────────
|
|
rem Configure or reconfigure with Meson
|
|
rem ──────────────────────────────────────────────────
|
|
if not exist "%BUILD_DIR%" (
|
|
echo [INFO] Creating build directory "%BUILD_DIR%" with backend "%BACKEND%" and build "%BUILD%"...
|
|
meson setup "%BUILD_DIR%" --backend=%BACKEND% --buildtype=%BUILD%
|
|
) else (
|
|
echo [INFO] Reconfiguring "%BUILD_DIR%" with backend "%BACKEND%" and build "%BUILD%"...
|
|
meson setup --reconfigure "%BUILD_DIR%" --backend=%BACKEND% --buildtype=%BUILD%
|
|
)
|
|
|
|
if errorlevel 1 (
|
|
echo [ERROR] Meson configuration failed.
|
|
exit /b 1
|
|
)
|
|
|
|
rem ──────────────────────────────────────────────────
|
|
rem Compile
|
|
rem ──────────────────────────────────────────────────
|
|
echo [INFO] Configuration succeeded—starting build...
|
|
meson compile -C "%BUILD_DIR%"
|
|
if errorlevel 1 (
|
|
echo [ERROR] Build failed.
|
|
exit /b 1
|
|
)
|
|
|
|
echo [SUCCESS] Build completed successfully.
|
|
exit /b 0
|
|
|
|
:usage
|
|
echo Usage: %~nx0 [backend] [build]
|
|
echo.
|
|
echo backend ninja (default) ^| vs2022 ^| vs2019 ^| vs2017
|
|
echo build debug (default) ^| debugoptimized ^| release ^| relwithdebinfo
|
|
exit /b 0
|