css_enhanced_waf/materialsystem/stdshaders/buildshaders.bat

146 lines
3.6 KiB
Batchfile
Raw Normal View History

2020-04-22 12:56:21 -04:00
@echo off
set TTEXE=..\..\devtools\bin\timeprecise.exe
if not exist %TTEXE% goto no_ttexe
goto no_ttexe_end
:no_ttexe
set TTEXE=time /t
:no_ttexe_end
echo.
2024-09-16 23:59:15 +02:00
echo ==================== buildshaders %* ==================
2020-04-22 12:56:21 -04:00
%TTEXE% -cur-Q
set tt_start=%ERRORLEVEL%
set tt_chkpt=%tt_start%
REM ****************
2024-09-16 23:59:15 +02:00
REM usage: buildshaders <shaderProjectName>
2020-04-22 12:56:21 -04:00
REM ****************
setlocal
set arg_filename=%1
2024-09-16 23:59:15 +02:00
set shadercompilecommand=ShaderCompile.exe
set targetdir=shaders
2020-04-22 12:56:21 -04:00
set SrcDirBase=..\..
set shaderDir=shaders
2024-09-16 23:59:15 +02:00
set SDKArgs=-local
2020-04-22 12:56:21 -04:00
if "%1" == "" goto usage
set inputbase=%1
2024-09-16 23:59:15 +02:00
REM ignore -dx9_30
if /i "%6" == "-dx9_30" shift /6
if /i "%6" == "-force30" goto set_force30_arg
2020-04-22 12:56:21 -04:00
goto set_force_end
:set_force30_arg
2024-09-16 23:59:15 +02:00
set IS30=1
2020-04-22 12:56:21 -04:00
goto set_force_end
:set_force_end
if /i "%2" == "-game" goto set_mod_args
goto build_shaders
REM ****************
REM USAGE
REM ****************
:usage
echo.
2024-09-16 23:59:15 +02:00
echo "usage: buildshaders <shaderProjectName> [-game] [gameDir if -game was specified] [-source sourceDir]"
2020-04-22 12:56:21 -04:00
echo " gameDir is where gameinfo.txt is (where it will store the compiled shaders)."
echo " sourceDir is where the source code is (where it will find scripts and compilers)."
echo "ex : buildshaders myshaders"
echo "ex : buildshaders myshaders -game c:\steam\steamapps\sourcemods\mymod -source c:\mymod\src"
goto :end
REM ****************
REM MOD ARGS - look for -game or the vproject environment variable
REM ****************
:set_mod_args
2024-09-16 23:59:15 +02:00
if not exist "..\..\devtools\bin\ShaderCompile.exe" goto NoShaderCompile
set ChangeToDir=%SrcDirBase%\devtools\bin\
2020-04-22 12:56:21 -04:00
if /i "%4" NEQ "-source" goto NoSourceDirSpecified
set SrcDirBase=%~5
REM ** use the -game parameter to tell us where to put the files
set targetdir=%~3\shaders
if not exist "%~3\gameinfo.txt" goto InvalidGameDirectory
2024-09-16 23:59:15 +02:00
if not exist "%inputbase%.txt" goto InvalidInputFile
2020-04-22 12:56:21 -04:00
goto build_shaders
REM ****************
REM ERRORS
REM ****************
:InvalidGameDirectory
echo Error: "%~3" is not a valid game directory.
echo (The -game directory must have a gameinfo.txt file)
2024-09-16 23:59:15 +02:00
goto end
:InvalidInputFile
echo Error: "%inputbase%.txt" is not a valid file.
2020-04-22 12:56:21 -04:00
goto end
:NoSourceDirSpecified
echo ERROR: If you specify -game on the command line, you must specify -source.
goto usage
goto end
:NoShaderCompile
2024-09-16 23:59:15 +02:00
echo - ERROR: ShaderCompile.exe doesn't exist in devtools\bin
2020-04-22 12:56:21 -04:00
goto end
REM ****************
REM BUILD SHADERS
REM ****************
:build_shaders
rem echo --------------------------------
rem echo %inputbase%
rem echo --------------------------------
REM make sure that target dirs exist
REM files will be built in these targets and copied to their final destination
2024-09-16 23:59:15 +02:00
if not exist include mkdir include
2020-04-22 12:56:21 -04:00
if not exist %shaderDir% mkdir %shaderDir%
if not exist %shaderDir%\fxc mkdir %shaderDir%\fxc
REM Nuke some files that we will add to later.
2024-09-16 23:59:15 +02:00
set SHVER=20b
if defined IS30 (
set SHVER=30
2020-04-22 12:56:21 -04:00
)
2024-09-16 23:59:15 +02:00
title %1 %SHVER%
2020-04-22 12:56:21 -04:00
2024-09-16 23:59:15 +02:00
echo Building inc files and worklist for %inputbase%...
2020-04-22 12:56:21 -04:00
2024-09-16 23:59:15 +02:00
set DYNAMIC=
if "%dynamic_shaders%" == "1" set DYNAMIC=-Dynamic
powershell -NoLogo -ExecutionPolicy Bypass -Command "%SrcDirBase%\devtools\bin\process_shaders.ps1 %DYNAMIC% -Version %SHVER% '%inputbase%.txt'"
2020-04-22 12:56:21 -04:00
REM ****************
2024-09-16 23:59:15 +02:00
REM PC Shader copy
REM Publish the generated files to the output dir using XCOPY
2020-04-22 12:56:21 -04:00
REM This batch file may have been invoked standalone or slaved (master does final smart mirror copy)
REM ****************
2024-09-16 23:59:15 +02:00
:DoXCopy
2020-04-22 12:56:21 -04:00
if not "%dynamic_shaders%" == "1" (
2024-09-16 23:59:15 +02:00
if not exist "%targetdir%" md "%targetdir%"
if not "%targetdir%"=="%shaderDir%" xcopy %shaderDir%\*.* "%targetdir%" /e /y
2020-04-22 12:56:21 -04:00
)
2024-09-16 23:59:15 +02:00
goto end
2020-04-22 12:56:21 -04:00
REM ****************
REM END
REM ****************
:end
%TTEXE% -diff %tt_start%
2024-09-16 23:59:15 +02:00
echo.