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