cracktro-1/buildgfx.bat

95 lines
5.4 KiB
Batchfile

@echo off
rem ---------------------------------------------------------------------------
rem D3D11 engine. Shaders are compiled here, at build time, and fxc writes
rem the C byte array itself (/Fh + /Vn) - so d3dcompiler_47.dll is never a
rem runtime dependency and there is no generator to maintain.
rem
rem buildgfx.bat release, windowed subsystem
rem buildgfx.bat offline no window, no sound: renders to bitmaps
rem ---------------------------------------------------------------------------
setlocal
cd /d "%~dp0"
set "VS=C:\Program Files\Microsoft Visual Studio\2022\Community"
if not exist "%VS%\VC\Auxiliary\Build\vcvars64.bat" set "VS=C:\Program Files\Microsoft Visual Studio\18\Community"
call "%VS%\VC\Auxiliary\Build\vcvars64.bat" >nul
set "FXC="
for /f "delims=" %%d in ('dir /b /ad /o-n "C:\Program Files (x86)\Windows Kits\10\bin\10.*" 2^>nul') do (
if not defined FXC if exist "C:\Program Files (x86)\Windows Kits\10\bin\%%d\x64\fxc.exe" set "FXC=C:\Program Files (x86)\Windows Kits\10\bin\%%d\x64\fxc.exe"
)
if not defined FXC ( echo [!] fxc.exe not found in the Windows SDK & exit /b 1 )
if not exist fx\out mkdir fx\out
rem /O3 optimises, /Ges enforces strict mode, /Qstrip_reflect and
rem /Qstrip_debug keep the blobs small - reflection data is dead weight in a
rem build that never queries it.
set "FXFLAGS=/nologo /O3 /Ges /Qstrip_reflect /Qstrip_debug"
echo [1/3] shaders
"%FXC%" %FXFLAGS% /T vs_5_0 /E main /Fh fx\out\fullscreen.h /Vn g_vsFullscreen fx\fullscreen.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T vs_5_0 /E main /Fh fx\out\mesh.h /Vn g_vsMeshBlob fx\mesh.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\meshps.h /Vn g_psMeshBlob fx\meshps.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\scene.h /Vn g_psSceneBlob fx\scene.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\logo.h /Vn g_psLogoBlob fx\logo.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\reactor.h /Vn g_psReactorBlob fx\reactor.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\orbital.h /Vn g_psOrbitalBlob fx\orbital.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\eye.h /Vn g_psEyeBlob fx\eye.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\void.h /Vn g_psVoidBlob fx\voidshot.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\horizon.h /Vn g_psHorizonBlob fx\horizon.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\kaleido.h /Vn g_psKaleidoBlob fx\kaleido.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\designframe.h /Vn g_psFramesBlob fx\designframe.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\plinths.h /Vn g_psPlinthBlob fx\plinths.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\drive.h /Vn g_psDriveBlob fx\drive.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\corridor.h /Vn g_psCorridorBlob fx\corridor.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\poweroff.h /Vn g_psPowerOffBlob fx\poweroff.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\burst.h /Vn g_psBurstBlob fx\burst.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\bloom.h /Vn g_psBloomBlob fx\bloom.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\c64.h /Vn g_psC64Blob fx\c64.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\signoff.h /Vn g_psSignBlob fx\signoff.hlsl || exit /b 1
"%FXC%" %FXFLAGS% /T ps_5_0 /E main /Fh fx\out\post.h /Vn g_psPostBlob fx\post.hlsl || exit /b 1
> shaders.h echo /* generated by buildgfx.bat - do not edit */
>> shaders.h echo #include "fx/out/fullscreen.h"
>> shaders.h echo #include "fx/out/mesh.h"
>> shaders.h echo #include "fx/out/meshps.h"
>> shaders.h echo #include "fx/out/scene.h"
>> shaders.h echo #include "fx/out/logo.h"
>> shaders.h echo #include "fx/out/reactor.h"
>> shaders.h echo #include "fx/out/orbital.h"
>> shaders.h echo #include "fx/out/eye.h"
>> shaders.h echo #include "fx/out/void.h"
>> shaders.h echo #include "fx/out/horizon.h"
>> shaders.h echo #include "fx/out/kaleido.h"
>> shaders.h echo #include "fx/out/designframe.h"
>> shaders.h echo #include "fx/out/plinths.h"
>> shaders.h echo #include "fx/out/drive.h"
>> shaders.h echo #include "fx/out/corridor.h"
>> shaders.h echo #include "fx/out/poweroff.h"
>> shaders.h echo #include "fx/out/burst.h"
>> shaders.h echo #include "fx/out/bloom.h"
>> shaders.h echo #include "fx/out/c64.h"
>> shaders.h echo #include "fx/out/signoff.h"
>> shaders.h echo #include "fx/out/post.h"
set "DEF="
set "SUB=WINDOWS"
set "OUT=CRTkafa.exe"
if /i "%~1"=="offline" ( set "DEF=/DOFFLINE" & set "SUB=WINDOWS" & set "OUT=gfxoffline.exe" )
if /i "%~1"=="video" ( set "DEF=/DVIDEO" & set "SUB=CONSOLE" & set "OUT=gfxvideo.exe" )
echo [2/3] compile
cl /nologo /c /O2 /Oi /GS- /fp:fast /std:c11 /W3 /wd4018 %DEF% /Fo:gfx.obj gfx.c || exit /b 1
echo [3/3] link
rem dxguid.lib is pure const GUID data with no CRT references, so it is safe
rem under /NODEFAULTLIB. d3d11.lib is deliberately NOT linked: the DLL is
rem resolved with LoadLibrary so a machine without it sees our message rather
rem than the loader's.
link /nologo /SUBSYSTEM:%SUB% /ENTRY:entry /NODEFAULTLIB /INCREMENTAL:NO ^
/OPT:REF /OPT:ICF ^
gfx.obj kernel32.lib user32.lib winmm.lib dxguid.lib /OUT:%OUT% || exit /b 1
for %%f in (%OUT%) do echo [ok] %%f = %%~zf bytes
for %%f in (fx\out\scene.h) do echo scene shader blob source = %%~zf bytes