hctstart.cmd 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. @echo off
  2. if "%1"=="/?" goto :showhelp
  3. if "%1"=="-?" goto :showhelp
  4. if "%1"=="-help" goto :showhelp
  5. if "%1"=="--help" goto :showhelp
  6. rem Default build arch is x64
  7. if "%BUILD_ARCH%"=="" (
  8. set BUILD_ARCH=x64
  9. )
  10. if "%1"=="-x86" (
  11. set BUILD_ARCH=Win32
  12. ) else if "%1"=="-Win32" (
  13. set BUILD_ARCH=Win32
  14. ) else if "%1"=="-x64" (
  15. set BUILD_ARCH=x64
  16. ) else if "%1"=="-amd64" (
  17. set BUILD_ARCH=x64
  18. ) else if "%1"=="-arm" (
  19. set BUILD_ARCH=ARM
  20. ) else if "%1"=="-arm64" (
  21. set BUILD_ARCH=ARM64
  22. ) else (
  23. goto :donearch
  24. )
  25. shift /1
  26. :donearch
  27. echo Default architecture - set BUILD_ARCH=%BUILD_ARCH%
  28. rem Set the following environment variable globally, or start Visual Studio
  29. rem from this command line in order to use 64-bit tools.
  30. set PreferredToolArchitecture=x64
  31. if "%1"=="" (
  32. echo Source directory missing.
  33. goto :showhelp
  34. )
  35. if "%2"=="" (
  36. echo Build directory missing.
  37. goto :showhelp
  38. )
  39. if not exist "%~f1\utils\hct\hctstart.cmd" (
  40. echo %1 does not look like a directory with sources - cannot find %~f1\utils\hct\hctstart.cmd
  41. exit /b 1
  42. )
  43. set HLSL_SRC_DIR=%~f1
  44. set HLSL_BLD_DIR=%~f2
  45. echo HLSL source directory set to HLSL_SRC_DIR=%HLSL_SRC_DIR%
  46. echo HLSL source directory set to HLSL_BLD_DIR=%HLSL_BLD_DIR%
  47. echo.
  48. echo You can recreate the environment with this command.
  49. echo %0 %*
  50. echo.
  51. echo Setting up macros for this console - run hcthelp for a reference.
  52. echo.
  53. doskey hctbld=pushd %HLSL_BLD_DIR%
  54. doskey hctbuild=%HLSL_SRC_DIR%\utils\hct\hctbuild.cmd $*
  55. doskey hctcheckin=%HLSL_SRC_DIR%\utils\hct\hctcheckin.cmd $*
  56. doskey hctclean=%HLSL_SRC_DIR%\utils\hct\hctclean.cmd $*
  57. doskey hcthelp=%HLSL_SRC_DIR%\utils\hct\hcthelp.cmd $*
  58. doskey hctshortcut=cscript.exe //Nologo %HLSL_SRC_DIR%\utils\hct\hctshortcut.js $*
  59. doskey hctspeak=cscript.exe //Nologo %HLSL_SRC_DIR%\utils\hct\hctspeak.js $*
  60. doskey hctsrc=pushd %HLSL_SRC_DIR%
  61. doskey hcttest=%HLSL_SRC_DIR%\utils\hct\hcttest.cmd $*
  62. doskey hcttools=pushd %HLSL_SRC_DIR%\utils\hct
  63. doskey hcttodo=cscript.exe //Nologo %HLSL_SRC_DIR%\utils\hct\hcttodo.js $*
  64. doskey hctvs=%HLSL_SRC_DIR%\utils\hct\hctvs.cmd $*
  65. call :checksdk
  66. if errorlevel 1 (
  67. echo Windows SDK not properly installed. Build enviornment could not be setup correctly.
  68. echo Please see the README.md instructions in the project root.
  69. exit /b 1
  70. )
  71. where cmake.exe 1>nul 2>nul
  72. if errorlevel 1 (
  73. call :findcmake
  74. )
  75. call :checkcmake
  76. if errorlevel 1 (
  77. echo WARNING: cmake version is not supported. Your build may fail.
  78. )
  79. where python.exe 1>nul 2>nul
  80. if errorlevel 1 (
  81. call :findpython
  82. )
  83. where te.exe 1>nul 2>nul
  84. if errorlevel 1 (
  85. call :findte
  86. )
  87. where git.exe 1>nul 2>nul
  88. if errorlevel 1 (
  89. call :findgit
  90. )
  91. pushd %HLSL_SRC_DIR%
  92. goto :eof
  93. :showhelp
  94. echo hctstart - Start the HLSL console tools environment.
  95. echo.
  96. echo This script sets up the sources and binary environment variables
  97. echo and installs convenience console aliases. See hcthelp for a reference.
  98. echo.
  99. echo Usage:
  100. echo hctstart [-x86 or -x64] [path-to-sources] [path-to-build]
  101. echo.
  102. goto :eof
  103. :findcmake
  104. call :ifexistaddpath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
  105. if "%ERRORLEVEL%"=="0" (
  106. echo Path adjusted to include cmake from Visual Studio 2017 Community
  107. exit /b 0
  108. )
  109. if errorlevel 1 if exist "%programfiles%\CMake\bin" set path=%path%;%programfiles%\CMake\bin
  110. if errorlevel 1 if exist "%programfiles(x86)%\CMake\bin" set path=%path%;%programfiles(x86)%\CMake\bin
  111. where cmake.exe 1>nul 2>nul
  112. if errorlevel 1 (
  113. echo Unable to find cmake on path - you will have to add this before building.
  114. exit /b 1
  115. )
  116. echo Path adjusted to include cmake.
  117. goto :eof
  118. :findte
  119. if exist "%programfiles%\windows kits\10\Testing\Runtimes\TAEF\Te.exe" set path=%path%;%programfiles%\windows kits\10\Testing\Runtimes\TAEF
  120. if exist "%programfiles(x86)%\windows kits\10\Testing\Runtimes\TAEF\Te.exe" set path=%path%;%programfiles(x86)%\windows kits\10\Testing\Runtimes\TAEF
  121. if exist "%programfiles%\windows kits\8.1\Testing\Runtimes\TAEF\Te.exe" set path=%path%;%programfiles%\windows kits\8.1\Testing\Runtimes\TAEF
  122. if exist "%programfiles(x86)%\windows kits\8.1\Testing\Runtimes\TAEF\Te.exe" set path=%path%;%programfiles(x86)%\windows kits\8.1\Testing\Runtimes\TAEF
  123. if exist "%HLSL_SRC_DIR%\external\taef\build\Binaries\amd64\TE.exe" set path=%path%;%HLSL_SRC_DIR%\external\taef\build\Binaries\amd64
  124. where te.exe 1>nul 2>nul
  125. if errorlevel 1 (
  126. echo Unable to find TAEF te.exe on path - you will have to add this before running tests.
  127. echo WDK includes TAEF and is available from https://msdn.microsoft.com/en-us/windows/hardware/dn913721.aspx
  128. echo Alternatively, consider a project-local install by running %HLSL_SRC_DIR%\utils\hct\hctgettaef.py
  129. echo Please see the README.md instructions in the project root.
  130. exit /b 1
  131. )
  132. echo Path adjusted to include TAEF te.exe.
  133. if "%BUILD_ARCH%"=="ARM" (
  134. echo.
  135. echo WARNING: ARM build is not supported. Your build may fail. Use ARM64 instead.
  136. )
  137. goto :eof
  138. :ifexistaddpath
  139. rem If the argument exists, add to PATH and return 0, else 1. Useful to avoid parens in values without setlocal changes.
  140. if exist %1 set PATH=%PATH%;%~1
  141. if exist %1 exit /b 0
  142. exit /b 1
  143. :findgit
  144. if exist "C:\Program Files (x86)\Git\cmd\git.exe" set path=%path%;C:\Program Files (x86)\Git\cmd
  145. if exist "C:\Program Files\Git\cmd\git.exe" set path=%path%;C:\Program Files\Git\cmd
  146. if exist "%LOCALAPPDATA%\Programs\Git\cmd\git.exe" set path=%path%;%LOCALAPPDATA%\Programs\Git\cmd
  147. where git 1>nul 2>nul
  148. if errorlevel 1 (
  149. echo Unable to find git. Having git is convenient but not necessary to build and test.
  150. )
  151. echo Path adjusted to include git.
  152. goto :eof
  153. :findpython
  154. if exist C:\Python27\python.exe set path=%path%;C:\Python27
  155. where python.exe 1>nul 2>nul
  156. if errorlevel 1 (
  157. echo Unable to find python.
  158. exit /b 1
  159. )
  160. echo Path adjusted to include python.
  161. goto :eof
  162. :checksdk
  163. setlocal
  164. set min_sdk_ver=14393
  165. set REG_QUERY=REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0"
  166. set kit_root=
  167. for /F "tokens=1,2*" %%A in ('%REG_QUERY% /v InstallationFolder') do (
  168. if "%%A"=="InstallationFolder" (
  169. rem echo Found Windows 10 SDK
  170. rem echo InstallationFolder: "%%C"
  171. set kit_root=%%C
  172. )
  173. )
  174. if ""=="%kit_root%" (
  175. echo Did not find a Windows 10 SDK installation.
  176. exit /b 1
  177. )
  178. if not exist "%kit_root%" (
  179. echo Windows 10 SDK was installed but is not accessible.
  180. exit /b 1
  181. )
  182. set sdk_ver=
  183. set d3d12_sdk_ver=
  184. for /F "tokens=1-3" %%A in ('%REG_QUERY% /v ProductVersion') do (
  185. if "%%A"=="ProductVersion" (
  186. rem echo ProductVersion: %%C
  187. for /F "tokens=1-3 delims=." %%X in ("%%C") do (
  188. set sdk_ver=%%Z
  189. if exist "%kit_root%\include\10.0.%%Z.0\um\d3d12.h" (
  190. set d3d12_sdk_ver=%%Z
  191. )
  192. )
  193. )
  194. )
  195. if ""=="%sdk_ver%" (
  196. echo Could not detect Windows 10 SDK version.
  197. exit /b 1
  198. )
  199. if NOT %min_sdk_ver% LEQ %sdk_ver% (
  200. echo Found unsupported Windows 10 SDK version 10.0.%sdk_ver%.0 installed.
  201. echo Windows 10 SDK version 10.0.%min_sdk_ver%.0 or newer is required.
  202. exit /b 1
  203. )
  204. if ""=="%d3d12_sdk_ver%" (
  205. echo Windows 10 SDK version 10.0.%sdk_ver%.0 installed, but did not find d3d12.h.
  206. exit /b 1
  207. ) else (
  208. echo Found Windows 10 SDK 10.0.%d3d12_sdk_ver%.0
  209. )
  210. endlocal
  211. goto :eof
  212. :checkcmake
  213. cmake --version | findstr 3.4.3 1>nul 2>nul
  214. if "0"=="%ERRORLEVEL%" exit /b 0
  215. cmake --version | findstr 3.7.2 1>nul 2>nul
  216. if "0"=="%ERRORLEVEL%" exit /b 0
  217. cmake --version | findstr 3.9.0-MSVC 1>nul 2>nul
  218. if "0"=="%ERRORLEVEL%" exit /b 0
  219. cmake --version | findstr 3.11.2 1>nul 2>nul
  220. if "0"=="%ERRORLEVEL%" exit /b 0
  221. cmake --version | findstr /R 3.6.*MSVC 1>nul 2>nul
  222. if errorlevel 1 (
  223. echo CMake 3.4.3, 3.7.2, 3.9.0 or 3.11.2 are the currently supported versions for VS 2015 and VS 2017 - your installed cmake is not supported.
  224. echo See README.md at the root for an explanation of dependencies.
  225. exit /b 1
  226. )
  227. goto :eof