Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

258 lines
7.7 KiB

  1. @echo off
  2. set TTEXE=..\..\devtools\bin\timeprecise.exe
  3. if not exist %TTEXE% goto no_ttexe
  4. goto no_ttexe_end
  5. :no_ttexe
  6. set TTEXE=time /t
  7. :no_ttexe_end
  8. echo.
  9. rem echo ==================== buildshaders %* ==================
  10. %TTEXE% -cur-Q
  11. set tt_start=%ERRORLEVEL%
  12. set tt_chkpt=%tt_start%
  13. REM ****************
  14. REM usage: buildshaders <shaderProjectName> [-x360]
  15. REM ****************
  16. setlocal
  17. set arg_filename=%1
  18. rem set shadercompilecommand=echo shadercompile.exe -mpi_graphics -mpi_TrackEvents
  19. set shadercompilecommand=shadercompile.exe
  20. set shadercompileworkers=128
  21. set x360_args=
  22. set targetdir=..\..\..\game\hl2\shaders
  23. set SrcDirBase=..\..
  24. set ChangeToDir=../../../game/bin
  25. set shaderDir=shaders
  26. set SDKArgs=
  27. set SHADERINCPATH=vshtmp9/... fxctmp9/...
  28. set DIRECTX_SDK_VER=pc09.00
  29. set DIRECTX_SDK_BIN_DIR=dx9sdk\utilities
  30. if /i "%2" == "-x360" goto dx_sdk_x360
  31. if /i "%2" == "-dx9_30" goto dx_sdk_dx9_30
  32. if /i "%2" == "-dx10" goto dx_sdk_dx10
  33. goto dx_sdk_end
  34. :dx_sdk_x360
  35. set DIRECTX_SDK_VER=x360.00
  36. set DIRECTX_SDK_BIN_DIR=x360xdk\bin\win32
  37. goto dx_sdk_end
  38. :dx_sdk_dx9_30
  39. set DIRECTX_SDK_VER=pc09.30
  40. set DIRECTX_SDK_BIN_DIR=dx10sdk\utilities\dx9_30
  41. goto dx_sdk_end
  42. :dx_sdk_dx10
  43. set DIRECTX_SDK_VER=pc10.00
  44. set DIRECTX_SDK_BIN_DIR=dx10sdk\utilities\dx10_40
  45. goto dx_sdk_end
  46. :dx_sdk_end
  47. if "%1" == "" goto usage
  48. set inputbase=%1
  49. if /i "%3" == "-force30" goto set_force30_arg
  50. goto set_force_end
  51. :set_force30_arg
  52. set DIRECTX_FORCE_MODEL=30
  53. goto set_force_end
  54. :set_force_end
  55. if /i "%2" == "-x360" goto set_x360_args
  56. if /i "%2" == "-game" goto set_mod_args
  57. goto build_shaders
  58. REM ****************
  59. REM USAGE
  60. REM ****************
  61. :usage
  62. echo.
  63. echo "usage: buildshaders <shaderProjectName> [-x360 or -dx10 or -game] [gameDir if -game was specified] [-source sourceDir]"
  64. echo " gameDir is where gameinfo.txt is (where it will store the compiled shaders)."
  65. echo " sourceDir is where the source code is (where it will find scripts and compilers)."
  66. echo "ex : buildshaders myshaders"
  67. echo "ex : buildshaders myshaders -game c:\steam\steamapps\sourcemods\mymod -source c:\mymod\src"
  68. goto :end
  69. REM ****************
  70. REM X360 ARGS
  71. REM ****************
  72. :set_x360_args
  73. set x360_args=-x360
  74. set SHADERINCPATH=vshtmp9_360/... fxctmp9_360/...
  75. goto build_shaders
  76. REM ****************
  77. REM MOD ARGS - look for -game or the vproject environment variable
  78. REM ****************
  79. :set_mod_args
  80. if not exist %sourcesdk%\bin\shadercompile.exe goto NoShaderCompile
  81. set ChangeToDir=%sourcesdk%\bin
  82. if /i "%4" NEQ "-source" goto NoSourceDirSpecified
  83. set SrcDirBase=%~5
  84. REM ** use the -game parameter to tell us where to put the files
  85. set targetdir=%~3\shaders
  86. set SDKArgs=-nompi -game "%~3"
  87. if not exist "%~3\gameinfo.txt" goto InvalidGameDirectory
  88. goto build_shaders
  89. REM ****************
  90. REM ERRORS
  91. REM ****************
  92. :InvalidGameDirectory
  93. echo -
  94. echo Error: "%~3" is not a valid game directory.
  95. echo (The -game directory must have a gameinfo.txt file)
  96. echo -
  97. goto end
  98. :NoSourceDirSpecified
  99. echo ERROR: If you specify -game on the command line, you must specify -source.
  100. goto usage
  101. goto end
  102. :NoShaderCompile
  103. echo -
  104. echo - ERROR: shadercompile.exe doesn't exist in %sourcesdk%\bin
  105. echo -
  106. goto end
  107. REM ****************
  108. REM BUILD SHADERS
  109. REM ****************
  110. :build_shaders
  111. rem echo --------------------------------
  112. rem echo %inputbase%
  113. rem echo --------------------------------
  114. REM make sure that target dirs exist
  115. REM files will be built in these targets and copied to their final destination
  116. if not exist %shaderDir% mkdir %shaderDir%
  117. if not exist %shaderDir%\fxc mkdir %shaderDir%\fxc
  118. if not exist %shaderDir%\vsh mkdir %shaderDir%\vsh
  119. if not exist %shaderDir%\psh mkdir %shaderDir%\psh
  120. REM Nuke some files that we will add to later.
  121. if exist filelist.txt del /f /q filelist.txt
  122. if exist filestocopy.txt del /f /q filestocopy.txt
  123. if exist filelistgen.txt del /f /q filelistgen.txt
  124. if exist inclist.txt del /f /q inclist.txt
  125. if exist vcslist.txt del /f /q vcslist.txt
  126. REM ****************
  127. REM Revert any targets (vcs or inc) that are opened for integrate.
  128. REM ****************
  129. perl "%SrcDirBase%\devtools\bin\p4revertshadertargets.pl" %x360_args% -source "%SrcDirBase%" %inputbase%
  130. REM ****************
  131. REM Generate a makefile for the shader project
  132. REM ****************
  133. perl "%SrcDirBase%\devtools\bin\updateshaders.pl" %x360_args% -source "%SrcDirBase%" %inputbase%
  134. REM ****************
  135. REM Run the makefile, generating minimal work/build list for fxc files, go ahead and compile vsh and psh files.
  136. REM ****************
  137. rem nmake /S /C -f makefile.%inputbase% clean > clean.txt 2>&1
  138. echo Building inc files, asm vcs files, and VMPI worklist for %inputbase%...
  139. nmake /S /C -f makefile.%inputbase%
  140. REM ****************
  141. REM Copy the inc files to their target
  142. REM ****************
  143. if exist "inclist.txt" (
  144. echo Publishing shader inc files to target...
  145. perl %SrcDirBase%\devtools\bin\copyshaderincfiles.pl inclist.txt %x360_args%
  146. )
  147. REM ****************
  148. REM Deal with perforce operations for inc files
  149. REM ****************
  150. if exist inclist.txt if not "%VALVE_NO_AUTO_P4_SHADERS%" == "1" (
  151. echo Executing perforce operations on .inc files.
  152. perl ..\..\devtools\bin\p4autocheckout.pl inclist.txt "Shader Auto Checkout INC" . %SHADERINCPATH%
  153. )
  154. REM ****************
  155. REM Add the executables to the worklist.
  156. REM ****************
  157. if /i "%DIRECTX_SDK_VER%" == "pc09.00" (
  158. rem echo "Copy extra files for dx 9 std
  159. )
  160. if /i "%DIRECTX_SDK_VER%" == "pc09.30" (
  161. echo %SrcDirBase%\devtools\bin\d3dx9_33.dll >> filestocopy.txt
  162. )
  163. if /i "%DIRECTX_SDK_VER%" == "pc10.00" (
  164. echo %SrcDirBase%\devtools\bin\d3dx10_33.dll >> filestocopy.txt
  165. )
  166. if /i "%DIRECTX_SDK_VER%" == "x360.00" (
  167. rem echo "Copy extra files for xbox360
  168. )
  169. echo %SrcDirBase%\%DIRECTX_SDK_BIN_DIR%\dx_proxy.dll >> filestocopy.txt
  170. echo %SrcDirBase%\..\game\bin\shadercompile.exe >> filestocopy.txt
  171. echo %SrcDirBase%\..\game\bin\shadercompile_dll.dll >> filestocopy.txt
  172. echo %SrcDirBase%\..\game\bin\vstdlib.dll >> filestocopy.txt
  173. echo %SrcDirBase%\..\game\bin\tier0.dll >> filestocopy.txt
  174. REM ****************
  175. REM Cull duplicate entries in work/build list
  176. REM ****************
  177. if exist filestocopy.txt type filestocopy.txt | perl "%SrcDirBase%\devtools\bin\uniqifylist.pl" > uniquefilestocopy.txt
  178. if exist filelistgen.txt if not "%dynamic_shaders%" == "1" (
  179. echo Generating action list...
  180. copy filelistgen.txt filelist.txt >nul
  181. rem %SrcDirBase%\devtools\bin\fxccombogen.exe <filelistgen.txt 1>nul 2>filelist.txt
  182. )
  183. REM ****************
  184. REM Execute distributed process on work/build list
  185. REM ****************
  186. set shader_path_cd=%cd%
  187. if exist "filelist.txt" if exist "uniquefilestocopy.txt" if not "%dynamic_shaders%" == "1" (
  188. echo Running distributed shader compilation...
  189. cd %ChangeToDir%
  190. %shadercompilecommand% -mpi_workercount %shadercompileworkers% -allowdebug -shaderpath "%shader_path_cd:/=\%" %x360_args% %SDKArgs%
  191. cd %shader_path_cd%
  192. )
  193. REM ****************
  194. REM PC and 360 Shader copy
  195. REM Publish the generated files to the output dir using ROBOCOPY (smart copy) or XCOPY
  196. REM This batch file may have been invoked standalone or slaved (master does final smart mirror copy)
  197. REM ****************
  198. if not "%dynamic_shaders%" == "1" (
  199. if exist makefile.%inputbase%.copy echo Publishing shaders to target...
  200. if exist makefile.%inputbase%.copy perl %SrcDirBase%\devtools\bin\copyshaders.pl makefile.%inputbase%.copy %x360_args%
  201. )
  202. REM ****************
  203. REM Deal with perforce operations for vcs files
  204. REM ****************
  205. if not "%dynamic_shaders%" == "1" if exist vcslist.txt if not "%VALVE_NO_AUTO_P4_SHADERS%" == "1" (
  206. echo Executing perforce operations on .vcs files.
  207. perl ..\..\devtools\bin\p4autocheckout.pl vcslist.txt "Shader Auto Checkout VCS" ../../../game/hl2/shaders ../../../game/hl2/shaders/...
  208. )
  209. REM ****************
  210. REM END
  211. REM ****************
  212. :end
  213. %TTEXE% -diff %tt_start%
  214. echo.