hctstart.cmd 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. call :ifexistaddpath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
  110. if "%ERRORLEVEL%"=="0" (
  111. echo Path adjusted to include cmake from Visual Studio 2017 Professional
  112. exit /b 0
  113. )
  114. call :ifexistaddpath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
  115. if "%ERRORLEVEL%"=="0" (
  116. echo Path adjusted to include cmake from Visual Studio 2017 Enterprise
  117. exit /b 0
  118. )
  119. if errorlevel 1 if exist "%programfiles%\CMake\bin" set path=%path%;%programfiles%\CMake\bin
  120. if errorlevel 1 if exist "%programfiles(x86)%\CMake\bin" set path=%path%;%programfiles(x86)%\CMake\bin
  121. where cmake.exe 1>nul 2>nul
  122. if errorlevel 1 (
  123. echo Unable to find cmake on path - you will have to add this before building.
  124. exit /b 1
  125. )
  126. echo Path adjusted to include cmake.
  127. goto :eof
  128. :findte
  129. if exist "%programfiles%\windows kits\10\Testing\Runtimes\TAEF\Te.exe" set path=%path%;%programfiles%\windows kits\10\Testing\Runtimes\TAEF
  130. if exist "%programfiles(x86)%\windows kits\10\Testing\Runtimes\TAEF\Te.exe" set path=%path%;%programfiles(x86)%\windows kits\10\Testing\Runtimes\TAEF
  131. if exist "%programfiles%\windows kits\8.1\Testing\Runtimes\TAEF\Te.exe" set path=%path%;%programfiles%\windows kits\8.1\Testing\Runtimes\TAEF
  132. 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
  133. if exist "%HLSL_SRC_DIR%\external\taef\build\Binaries\amd64\TE.exe" set path=%path%;%HLSL_SRC_DIR%\external\taef\build\Binaries\amd64
  134. where te.exe 1>nul 2>nul
  135. if errorlevel 1 (
  136. echo Unable to find TAEF te.exe on path - you will have to add this before running tests.
  137. echo WDK includes TAEF and is available from https://msdn.microsoft.com/en-us/windows/hardware/dn913721.aspx
  138. echo Alternatively, consider a project-local install by running %HLSL_SRC_DIR%\utils\hct\hctgettaef.py
  139. echo Please see the README.md instructions in the project root.
  140. exit /b 1
  141. )
  142. echo Path adjusted to include TAEF te.exe.
  143. if "%BUILD_ARCH%"=="ARM" (
  144. echo.
  145. echo WARNING: ARM build is not supported. Your build may fail. Use ARM64 instead.
  146. )
  147. goto :eof
  148. :ifexistaddpath
  149. rem If the argument exists, add to PATH and return 0, else 1. Useful to avoid parens in values without setlocal changes.
  150. if exist %1 set PATH=%PATH%;%~1
  151. if exist %1 exit /b 0
  152. exit /b 1
  153. :findgit
  154. if exist "C:\Program Files (x86)\Git\cmd\git.exe" set path=%path%;C:\Program Files (x86)\Git\cmd
  155. if exist "C:\Program Files\Git\cmd\git.exe" set path=%path%;C:\Program Files\Git\cmd
  156. if exist "%LOCALAPPDATA%\Programs\Git\cmd\git.exe" set path=%path%;%LOCALAPPDATA%\Programs\Git\cmd
  157. where git 1>nul 2>nul
  158. if errorlevel 1 (
  159. echo Unable to find git. Having git is convenient but not necessary to build and test.
  160. )
  161. echo Path adjusted to include git.
  162. goto :eof
  163. :findpython
  164. if exist C:\Python37\python.exe set path=%path%;C:\Python37
  165. where python.exe 1>nul 2>nul
  166. if errorlevel 1 (
  167. echo Unable to find python.
  168. exit /b 1
  169. )
  170. echo Path adjusted to include python.
  171. goto :eof
  172. :checksdk
  173. setlocal
  174. set min_sdk_ver=14393
  175. set REG_QUERY=REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0"
  176. set kit_root=
  177. for /F "tokens=1,2*" %%A in ('%REG_QUERY% /v InstallationFolder') do (
  178. if "%%A"=="InstallationFolder" (
  179. rem echo Found Windows 10 SDK
  180. rem echo InstallationFolder: "%%C"
  181. set kit_root=%%C
  182. )
  183. )
  184. if ""=="%kit_root%" (
  185. set kit_root=%WIN10_SDK_PATH%
  186. )
  187. if ""=="%kit_root%" (
  188. echo Did not find a Windows 10 SDK installation.
  189. exit /b 1
  190. )
  191. if not exist "%kit_root%" (
  192. echo Windows 10 SDK was installed but is not accessible.
  193. exit /b 1
  194. )
  195. set sdk_ver=
  196. set d3d12_sdk_ver=
  197. for /F "tokens=1-3" %%A in ('%REG_QUERY% /v ProductVersion') do (
  198. if "%%A"=="ProductVersion" (
  199. rem echo ProductVersion: %%C
  200. for /F "tokens=1-3 delims=." %%X in ("%%C") do (
  201. set sdk_ver=%%Z
  202. if exist "%kit_root%\include\10.0.%%Z.0\um\d3d12.h" (
  203. set d3d12_sdk_ver=%%Z
  204. )
  205. )
  206. )
  207. )
  208. if ""=="%sdk_ver%" (
  209. set sdk_ver=%WIN10_SDK_VERSION%
  210. )
  211. if ""=="%sdk_ver%" (
  212. echo Could not detect Windows 10 SDK version.
  213. exit /b 1
  214. )
  215. if NOT %min_sdk_ver% LEQ %sdk_ver% (
  216. echo Found unsupported Windows 10 SDK version 10.0.%sdk_ver%.0 installed.
  217. echo Windows 10 SDK version 10.0.%min_sdk_ver%.0 or newer is required.
  218. exit /b 1
  219. )
  220. if ""=="%d3d12_sdk_ver%" (
  221. echo Windows 10 SDK version 10.0.%sdk_ver%.0 installed, but did not find d3d12.h.
  222. exit /b 1
  223. ) else (
  224. echo Found Windows 10 SDK 10.0.%d3d12_sdk_ver%.0
  225. )
  226. endlocal
  227. goto :eof
  228. :checkcmake
  229. cmake --version | findstr 3.4.3 1>nul 2>nul
  230. if "0"=="%ERRORLEVEL%" exit /b 0
  231. cmake --version | findstr 3.7.2 1>nul 2>nul
  232. if "0"=="%ERRORLEVEL%" exit /b 0
  233. cmake --version | findstr 3.9.0-MSVC 1>nul 2>nul
  234. if "0"=="%ERRORLEVEL%" exit /b 0
  235. cmake --version | findstr 3.11.2 1>nul 2>nul
  236. if "0"=="%ERRORLEVEL%" exit /b 0
  237. cmake --version | findstr /R 3.*MSVC 1>nul 2>nul
  238. if errorlevel 1 (
  239. 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.
  240. echo See README.md at the root for an explanation of dependencies.
  241. exit /b 1
  242. )
  243. goto :eof