67 lines
2.1 KiB
Batchfile
67 lines
2.1 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
cd /D "%~dp0"
|
|
if not exist build mkdir build
|
|
pushd build
|
|
|
|
for %%a in (%*) do set "%%a=1"
|
|
set program_build_cmd=meta.exe %*
|
|
set meta_build_warnings=-W4 -WX -we4668 -wd4244 -wd4201 -wd4324 -wd4100 -wd4101 -wd4189 -wd4200 -wd4702 -wd4305
|
|
set meta_build_cmd=cl.exe ../src/meta/meta.c -Od -Z7 -nologo -diagnostics:column %meta_build_warnings% -link -DEBUG:FULL -INCREMENTAL:NO
|
|
set meta_rebuild_code=1317212284
|
|
|
|
if "%--force_meta_build%"=="1" (
|
|
if exist meta.exe del meta.exe
|
|
)
|
|
|
|
echo build_cmd: %program_build_cmd%
|
|
|
|
::- Try to activate Visual Studio if devenv not detected
|
|
:: Taken from wcap: https://github.com/mmozeiko/wcap/blob/aa25ccb806d7a6e1c0bfdcca863aabcd8e9badfa/build.cmd#L21-L29
|
|
if "%PROCESSOR_ARCHITECTURE%" equ "AMD64" (
|
|
set HOST_ARCH=x64
|
|
) else if "%PROCESSOR_ARCHITECTURE%" equ "ARM64" (
|
|
set HOST_ARCH=arm64
|
|
)
|
|
where /Q cl.exe || (
|
|
echo **************************************************************************
|
|
echo WARNING: cl.exe not found, attempting to locate Visual Studio installation
|
|
|
|
set __VSCMD_ARG_NO_LOGO=1
|
|
for /f "tokens=*" %%i in ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i
|
|
if "!VS!" equ "" (
|
|
echo ERROR: Visual Studio installation not found
|
|
exit /b 1
|
|
)
|
|
echo Visual Studio installation located, activating development environment...
|
|
call "!VS!\Common7\Tools\VsDevCmd.bat" -arch=%HOST_ARCH% -host_arch=%HOST_ARCH% -startdir=none -no_logo || exit /b 1
|
|
echo Visual studio development environment activated
|
|
echo **************************************************************************
|
|
)
|
|
|
|
::- Meta build
|
|
:meta_build
|
|
if not exist meta.exe (
|
|
echo ====== Meta build =====
|
|
%meta_build_cmd%
|
|
set "rc=!errorlevel!"
|
|
if !rc! NEQ 0 (
|
|
if exist meta.exe del meta.exe
|
|
exit /b !rc!
|
|
)
|
|
)
|
|
|
|
::- Program build
|
|
if not "%--no_program_build%"=="1" (
|
|
echo ======== Build ========
|
|
%program_build_cmd%
|
|
set "rc=!errorlevel!"
|
|
if !rc! NEQ 0 (
|
|
if !rc! EQU %meta_rebuild_code% (
|
|
del meta.exe
|
|
goto meta_build
|
|
)
|
|
exit /b !rc!
|
|
)
|
|
)
|