hctstart.cmd 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. where python.exe 1>nul 2>nul
  76. if errorlevel 1 (
  77. call :findpython
  78. )
  79. where te.exe 1>nul 2>nul
  80. if errorlevel 1 (
  81. call :findte
  82. )
  83. where git.exe 1>nul 2>nul
  84. if errorlevel 1 (
  85. call :findgit
  86. )
  87. pushd %HLSL_SRC_DIR%
  88. goto :eof
  89. :showhelp
  90. echo hctstart - Start the HLSL console tools environment.
  91. echo.
  92. echo This script sets up the sources and binary environment variables
  93. echo and installs convenience console aliases. See hcthelp for a reference.
  94. echo.
  95. echo Usage:
  96. echo hctstart [-x86 or -x64] [path-to-sources] [path-to-build]
  97. echo.
  98. goto :eof
  99. :findcmake
  100. for %%v in (2019 2017) do (
  101. for %%e in (Community Professional Enterprise) do (
  102. if exist "%programfiles(x86)%\Microsoft Visual Studio\%%v\%%e\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" (
  103. set "PATH=%PATH%;%programfiles(x86)%\Microsoft Visual Studio\%%v\%%e\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
  104. echo Path adjusted to include cmake from Visual Studio %%v %%e.
  105. exit /b 0
  106. )
  107. )
  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. :findgit
  134. if exist "%programfiles(x86)%\Git\cmd\git.exe" set path=%path%;%programfiles(x86)%\Git\cmd
  135. if exist "%programfiles%\Git\cmd\git.exe" set path=%path%;%programfiles%\Git\cmd
  136. if exist "%LOCALAPPDATA%\Programs\Git\cmd\git.exe" set path=%path%;%LOCALAPPDATA%\Programs\Git\cmd
  137. where git 1>nul 2>nul
  138. if errorlevel 1 (
  139. echo Unable to find git. Having git is convenient but not necessary to build and test.
  140. )
  141. echo Path adjusted to include git.
  142. goto :eof
  143. :findpython
  144. if exist C:\Python37\python.exe set path=%path%;C:\Python37
  145. where python.exe 1>nul 2>nul
  146. if errorlevel 1 (
  147. echo Unable to find python.
  148. exit /b 1
  149. )
  150. echo Path adjusted to include python.
  151. goto :eof
  152. :checksdk
  153. setlocal
  154. set min_sdk_ver=14393
  155. set REG_QUERY=REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0"
  156. set kit_root=
  157. for /F "tokens=1,2*" %%A in ('%REG_QUERY% /v InstallationFolder') do (
  158. if "%%A"=="InstallationFolder" (
  159. rem echo Found Windows 10 SDK
  160. rem echo InstallationFolder: "%%C"
  161. set kit_root=%%C
  162. )
  163. )
  164. if ""=="%kit_root%" (
  165. set kit_root=%WIN10_SDK_PATH%
  166. )
  167. if ""=="%kit_root%" (
  168. echo Did not find a Windows 10 SDK installation.
  169. exit /b 1
  170. )
  171. if not exist "%kit_root%" (
  172. echo Windows 10 SDK was installed but is not accessible.
  173. exit /b 1
  174. )
  175. set sdk_ver=
  176. set d3d12_sdk_ver=
  177. for /F "tokens=1-3" %%A in ('%REG_QUERY% /v ProductVersion') do (
  178. if "%%A"=="ProductVersion" (
  179. rem echo ProductVersion: %%C
  180. for /F "tokens=1-3 delims=." %%X in ("%%C") do (
  181. set sdk_ver=%%Z
  182. if exist "%kit_root%\include\10.0.%%Z.0\um\d3d12.h" (
  183. set d3d12_sdk_ver=%%Z
  184. )
  185. )
  186. )
  187. )
  188. if ""=="%sdk_ver%" (
  189. set sdk_ver=%WIN10_SDK_VERSION%
  190. )
  191. if ""=="%sdk_ver%" (
  192. echo Could not detect Windows 10 SDK version.
  193. exit /b 1
  194. )
  195. if NOT %min_sdk_ver% LEQ %sdk_ver% (
  196. echo Found unsupported Windows 10 SDK version 10.0.%sdk_ver%.0 installed.
  197. echo Windows 10 SDK version 10.0.%min_sdk_ver%.0 or newer is required.
  198. exit /b 1
  199. )
  200. if ""=="%d3d12_sdk_ver%" (
  201. echo Windows 10 SDK version 10.0.%sdk_ver%.0 installed, but did not find d3d12.h.
  202. exit /b 1
  203. ) else (
  204. echo Found Windows 10 SDK 10.0.%d3d12_sdk_ver%.0
  205. )
  206. endlocal
  207. goto :eof
  208. endlocal