1@echo off 2REM Update source for glslang, spirv-tools 3 4REM Determine the appropriate CMake strings for the current version of Visual Studio 5echo Determining VS version 6python .\determine_vs_version.py > vsversion.tmp 7set /p VS_VERSION=< vsversion.tmp 8echo Detected Visual Studio Version as %VS_VERSION% 9 10REM Cleanup the file we used to collect the VS version output since it's no longer needed. 11del /Q /F vsversion.tmp 12 13setlocal EnableDelayedExpansion 14set errorCode=0 15set BUILD_DIR=%~dp0 16set BASE_DIR=%BUILD_DIR%.. 17set GLSLANG_DIR=%BASE_DIR%\glslang 18set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools 19 20REM // ======== Parameter parsing ======== // 21 22 if "%1" == "" ( 23 echo usage: update_external_sources.bat [options] 24 echo. 25 echo Available options: 26 echo --sync-glslang just pull glslang_revision 27 echo --sync-spirv-tools just pull spirv-tools_revision 28 echo --build-glslang pulls glslang_revision, configures CMake, builds Release and Debug 29 echo --build-spirv-tools pulls spirv-tools_revision, configures CMake, builds Release and Debug 30 echo --all sync and build glslang, LunarGLASS, spirv-tools 31 goto:finish 32 ) 33 34 set sync-glslang=0 35 set sync-spirv-tools=0 36 set build-glslang=0 37 set build-spirv-tools=0 38 set check-glslang-build-dependencies=0 39 40 :parameterLoop 41 42 if "%1"=="" goto:parameterContinue 43 44 if "%1" == "--sync-glslang" ( 45 set sync-glslang=1 46 shift 47 goto:parameterLoop 48 ) 49 50 if "%1" == "--sync-spirv-tools" ( 51 set sync-spirv-tools=1 52 shift 53 goto:parameterLoop 54 ) 55 56 if "%1" == "--build-glslang" ( 57 set sync-glslang=1 58 set check-glslang-build-dependencies=1 59 set build-glslang=1 60 shift 61 goto:parameterLoop 62 ) 63 64 if "%1" == "--build-spirv-tools" ( 65 set sync-spirv-tools=1 66 REM glslang has the same needs as spirv-tools 67 set check-glslang-build-dependencies=1 68 set build-spirv-tools=1 69 shift 70 goto:parameterLoop 71 ) 72 73 if "%1" == "--all" ( 74 set sync-glslang=1 75 set sync-spirv-tools=1 76 set build-glslang=1 77 set build-spirv-tools=1 78 set check-glslang-build-dependencies=1 79 shift 80 goto:parameterLoop 81 ) 82 83 echo Unrecognized options "%1" 84 goto:error 85 86 :parameterContinue 87 88REM // ======== end Parameter parsing ======== // 89 90 91REM // ======== Dependency checking ======== // 92 REM git is required for all paths 93 for %%X in (git.exe) do (set FOUND=%%~$PATH:X) 94 if not defined FOUND ( 95 echo Dependency check failed: 96 echo git.exe not found 97 echo Git for Windows can be downloaded here: https://git-scm.com/download/win 98 echo Install and ensure git.exe makes it into your PATH 99 set errorCode=1 100 ) 101 102 if %check-glslang-build-dependencies% equ 1 ( 103 for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X) 104 if not defined FOUND ( 105 echo Dependency check failed: 106 echo cmake.exe not found 107 echo Get CNake 2.8 for Windows here: http://www.cmake.org/cmake/resources/software.html 108 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin" 109 set errorCode=1 110 ) 111 ) 112 113 114 REM goto:main 115 116REM // ======== end Dependency checking ======== // 117 118:main 119 120if %errorCode% neq 0 (goto:error) 121 122REM Read the target versions from external file, which is shared with Linux script 123 124if not exist glslang_revision ( 125 echo. 126 echo Missing glslang_revision file! Place it next to this script with target version in it. 127 set errorCode=1 128 goto:error 129) 130 131if not exist spirv-tools_revision ( 132 echo. 133 echo Missing spirv-tools_revision file! Place it next to this script with target version in it. 134 set errorCode=1 135 goto:error 136) 137 138set /p GLSLANG_REVISION= < glslang_revision 139set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision 140echo GLSLANG_REVISION=%GLSLANG_REVISION% 141echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION% 142 143 144echo Creating and/or updating glslang, spirv-tools in %BASE_DIR% 145 146if %sync-glslang% equ 1 ( 147 if exist %GLSLANG_DIR% ( 148 rd /S /Q %GLSLANG_DIR% 149 ) 150 if not exist %GLSLANG_DIR% ( 151 call:create_glslang 152 ) 153 if %errorCode% neq 0 (goto:error) 154 call:update_glslang 155 if %errorCode% neq 0 (goto:error) 156) 157 158if %sync-spirv-tools% equ 1 ( 159 if exist %SPIRV_TOOLS_DIR% ( 160 rd /S /Q %SPIRV_TOOLS_DIR% 161 ) 162 if %errorlevel% neq 0 (goto:error) 163 if not exist %SPIRV_TOOLS_DIR% ( 164 call:create_spirv-tools 165 ) 166 if %errorCode% neq 0 (goto:error) 167 call:update_spirv-tools 168 if %errorCode% neq 0 (goto:error) 169) 170 171if %build-glslang% equ 1 ( 172 call:build_glslang 173 if %errorCode% neq 0 (goto:error) 174) 175 176if %build-spirv-tools% equ 1 ( 177 call:build_spirv-tools 178 if %errorCode% neq 0 (goto:error) 179) 180 181echo. 182echo Exiting 183goto:finish 184 185:error 186echo. 187echo Halting due to error 188goto:finish 189 190:finish 191if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% ) 192endlocal 193goto:eof 194 195 196 197REM // ======== Functions ======== // 198 199:create_glslang 200 echo. 201 echo Creating local glslang repository %GLSLANG_DIR%) 202 mkdir %GLSLANG_DIR% 203 cd %GLSLANG_DIR% 204 git clone https://github.com/KhronosGroup/glslang.git . 205 git checkout %GLSLANG_REVISION% 206 if not exist %GLSLANG_DIR%\SPIRV ( 207 echo glslang source download failed! 208 set errorCode=1 209 ) 210goto:eof 211 212:update_glslang 213 echo. 214 echo Updating %GLSLANG_DIR% 215 cd %GLSLANG_DIR% 216 git fetch --all 217 git checkout %GLSLANG_REVISION% 218goto:eof 219 220:create_spirv-tools 221 echo. 222 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%) 223 mkdir %SPIRV_TOOLS_DIR% 224 cd %SPIRV_TOOLS_DIR% 225 git clone https://github.com/KhronosGroup/SPIRV-Tools.git . 226 git checkout %SPIRV_TOOLS_REVISION% 227 if not exist %SPIRV_TOOLS_DIR%\source ( 228 echo spirv-tools source download failed! 229 set errorCode=1 230 ) 231goto:eof 232 233:update_spirv-tools 234 echo. 235 echo Updating %SPIRV_TOOLS_DIR% 236 cd %SPIRV_TOOLS_DIR% 237 git fetch --all 238 git checkout %SPIRV_TOOLS_REVISION% 239goto:eof 240 241:build_glslang 242 echo. 243 echo Building %GLSLANG_DIR% 244 cd %GLSLANG_DIR% 245 246 REM Cleanup any old directories lying around. 247 if exist build32 ( 248 rmdir /s /q build32 249 ) 250 if exist build ( 251 rmdir /s /q build 252 ) 253 254 echo Making 32-bit glslang 255 echo ************************* 256 mkdir build32 257 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32 258 cd %GLSLANG_BUILD_DIR% 259 260 echo Generating 32-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install .. 261 cmake -G "Visual Studio %VS_VERSION%" -DCMAKE_INSTALL_PREFIX=install .. 262 263 echo Building 32-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug 264 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet 265 266 REM Check for existence of one lib, even though we should check for all results 267 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslang.lib ( 268 echo. 269 echo glslang 32-bit Debug build failed! 270 set errorCode=1 271 ) 272 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release 273 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet 274 275 REM Check for existence of one lib, even though we should check for all results 276 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib ( 277 echo. 278 echo glslang 32-bit Release build failed! 279 set errorCode=1 280 ) 281 282 cd .. 283 284 echo Making 64-bit glslang 285 echo ************************* 286 mkdir build 287 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build 288 cd %GLSLANG_BUILD_DIR% 289 290 echo Generating 64-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install .. 291 cmake -G "Visual Studio %VS_VERSION% Win64" -DCMAKE_INSTALL_PREFIX=install .. 292 293 echo Building 64-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug 294 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet 295 296 REM Check for existence of one lib, even though we should check for all results 297 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslang.lib ( 298 echo. 299 echo glslang 64-bit Debug build failed! 300 set errorCode=1 301 ) 302 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release 303 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet 304 305 REM Check for existence of one lib, even though we should check for all results 306 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib ( 307 echo. 308 echo glslang 64-bit Release build failed! 309 set errorCode=1 310 ) 311goto:eof 312 313:build_spirv-tools 314 echo. 315 echo Building %SPIRV_TOOLS_DIR% 316 cd %SPIRV_TOOLS_DIR% 317 318 REM Cleanup any old directories lying around. 319 if exist build32 ( 320 rmdir /s /q build32 321 ) 322 if exist build ( 323 rmdir /s /q build 324 ) 325 326 echo Making 32-bit spirv-tools 327 echo ************************* 328 mkdir build32 329 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build32 330 331 cd %SPIRV_TOOLS_BUILD_DIR% 332 333 echo Generating 32-bit spirv-tools CMake files for Visual Studio %VS_VERSION% .. 334 cmake -G "Visual Studio %VS_VERSION%" .. 335 336 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug 337 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet 338 339 REM Check for existence of one lib, even though we should check for all results 340 if not exist %SPIRV_TOOLS_BUILD_DIR%\Debug\SPIRV-Tools.lib ( 341 echo. 342 echo spirv-tools 32-bit Debug build failed! 343 set errorCode=1 344 ) 345 346 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release 347 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet 348 349 REM Check for existence of one lib, even though we should check for all results 350 if not exist %SPIRV_TOOLS_BUILD_DIR%\Release\SPIRV-Tools.lib ( 351 echo. 352 echo spirv-tools 32-bit Release build failed! 353 set errorCode=1 354 ) 355 356 cd .. 357 358 echo Making 64-bit spirv-tools 359 echo ************************* 360 mkdir build 361 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build 362 cd %SPIRV_TOOLS_BUILD_DIR% 363 364 echo Generating 64-bit spirv-tools CMake files for Visual Studio %VS_VERSION% .. 365 cmake -G "Visual Studio %VS_VERSION% Win64" .. 366 367 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug 368 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet 369 370 REM Check for existence of one lib, even though we should check for all results 371 if not exist %SPIRV_TOOLS_BUILD_DIR%\Debug\SPIRV-Tools.lib ( 372 echo. 373 echo spirv-tools 64-bit Debug build failed! 374 set errorCode=1 375 ) 376 377 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release 378 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet 379 380 REM Check for existence of one lib, even though we should check for all results 381 if not exist %SPIRV_TOOLS_BUILD_DIR%\Release\SPIRV-Tools.lib ( 382 echo. 383 echo spirv-tools 64-bit Release build failed! 384 set errorCode=1 385 ) 386goto:eof 387