71 lines
3.5 KiB
Batchfile
71 lines
3.5 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
rem ──────────────────────────────────────────────────
|
|
rem Defaults (override by passing [backend] [build])
|
|
rem ──────────────────────────────────────────────────
|
|
set BUILD_DIR=builddir
|
|
set BACKEND=ninja
|
|
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 Bootstrap Visual Studio if requested
|
|
rem ──────────────────────────────────────────────────
|
|
if /I "%BACKEND:~0,2%"=="vs" (
|
|
echo [INFO] Initializing Visual Studio environment for %BACKEND%...
|
|
call "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo [ERROR] Failed to initialize VS environment. Check the vcvarsall.bat path.
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
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
|