hctstart.cmd 7.3 KB

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