2 REM Update source for glslang, spirv-tools
4 REM Determine the appropriate CMake strings for the current version of Visual Studio
5 echo Determining VS version
6 python .\determine_vs_version.py > vsversion.tmp
7 set /p VS_VERSION=< vsversion.tmp
8 echo Detected Visual Studio Version as %VS_VERSION%
10 REM Cleanup the file we used to collect the VS version output since it's no longer needed.
11 del /Q /F vsversion.tmp
13 setlocal EnableDelayedExpansion
16 set BASE_DIR="%BUILD_DIR%external"
17 set GLSLANG_DIR=%BASE_DIR%\glslang
18 set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools
20 REM // ======== Parameter parsing ======== //
23 echo usage: update_external_sources.bat [options]
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
35 set sync-spirv-tools=0
37 set build-spirv-tools=0
38 set check-glslang-build-dependencies=0
42 if "%1"=="" goto:parameterContinue
44 if "%1" == "--sync-glslang" (
50 if "%1" == "--sync-spirv-tools" (
51 set sync-spirv-tools=1
56 if "%1" == "--build-glslang" (
58 set check-glslang-build-dependencies=1
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
75 set sync-spirv-tools=1
77 set build-spirv-tools=1
78 set check-glslang-build-dependencies=1
83 echo Unrecognized options "%1"
88 REM // ======== end Parameter parsing ======== //
91 REM // ======== 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
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"
116 REM // ======== end Dependency checking ======== //
120 if %errorCode% neq 0 (goto:error)
122 REM Read the target versions from external file, which is shared with Linux script
124 if not exist glslang_revision (
126 echo Missing glslang_revision file! Place it next to this script with target version in it.
131 if not exist spirv-tools_revision (
133 echo Missing spirv-tools_revision file! Place it next to this script with target version in it.
138 set /p GLSLANG_REVISION= < glslang_revision
139 set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision
140 set /p SPIRV_HEADERS_REVISION= < spirv-headers_revision
141 echo GLSLANG_REVISION=%GLSLANG_REVISION%
142 echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
143 echo SPIRV_HEADERS_REVISION=%SPIRV_HEADERS_REVISION%
146 echo Creating and/or updating glslang, spirv-tools in %BASE_DIR%
148 if %sync-glslang% equ 1 (
149 if exist %GLSLANG_DIR% (
150 rd /S /Q %GLSLANG_DIR%
152 if not exist %GLSLANG_DIR% (
155 if %errorCode% neq 0 (goto:error)
157 if %errorCode% neq 0 (goto:error)
160 if %sync-spirv-tools% equ 1 (
161 if exist %SPIRV_TOOLS_DIR% (
162 rd /S /Q %SPIRV_TOOLS_DIR%
164 if %errorlevel% neq 0 (goto:error)
165 if not exist %SPIRV_TOOLS_DIR% (
166 call:create_spirv-tools
168 if %errorCode% neq 0 (goto:error)
169 call:update_spirv-tools
170 if %errorCode% neq 0 (goto:error)
173 if %build-glslang% equ 1 (
175 if %errorCode% neq 0 (goto:error)
178 if %build-spirv-tools% equ 1 (
179 call:build_spirv-tools
180 if %errorCode% neq 0 (goto:error)
189 echo Halting due to error
193 if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
199 REM // ======== Functions ======== //
203 echo Creating local glslang repository %GLSLANG_DIR%)
206 git clone https://github.com/KhronosGroup/glslang.git .
207 git checkout %GLSLANG_REVISION%
208 if not exist %GLSLANG_DIR%\SPIRV (
209 echo glslang source download failed!
216 echo Updating %GLSLANG_DIR%
219 git checkout %GLSLANG_REVISION%
224 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%)
225 mkdir %SPIRV_TOOLS_DIR%
227 git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
228 git checkout %SPIRV_TOOLS_REVISION%
229 if not exist %SPIRV_TOOLS_DIR%\source (
230 echo spirv-tools source download failed!
233 mkdir %SPIRV_TOOLS_DIR%\external
234 mkdir %SPIRV_TOOLS_DIR%\external\spirv-headers
235 cd %SPIRV_TOOLS_DIR%\external\spirv-headers
236 git clone https://github.com/KhronosGroup/SPIRV-HEADERS.git .
237 git checkout %SPIRV_HEADERS_REVISION%
238 if not exist %SPIRV_TOOLS_DIR%\external\spirv-headers\README.md (
239 echo spirv-headers download failed!
246 echo Updating %SPIRV_TOOLS_DIR%
249 git checkout %SPIRV_TOOLS_REVISION%
250 cd %SPIRV_TOOLS_DIR%\external\spirv-headers
252 git checkout %SPIRV_HEADERS_REVISION%
257 echo Building %GLSLANG_DIR%
260 REM Cleanup any old directories lying around.
268 echo Making 32-bit glslang
269 echo *************************
271 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32
272 cd %GLSLANG_BUILD_DIR%
274 echo Generating 32-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
275 cmake -G "Visual Studio %VS_VERSION%" -DCMAKE_INSTALL_PREFIX=install ..
277 echo Building 32-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug
278 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
280 REM Check for existence of one lib, even though we should check for all results
281 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
283 echo glslang 32-bit Debug build failed!
286 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release
287 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
289 REM Check for existence of one lib, even though we should check for all results
290 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
292 echo glslang 32-bit Release build failed!
298 echo Making 64-bit glslang
299 echo *************************
301 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
302 cd %GLSLANG_BUILD_DIR%
304 echo Generating 64-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
305 cmake -G "Visual Studio %VS_VERSION% Win64" -DCMAKE_INSTALL_PREFIX=install ..
307 echo Building 64-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
308 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
310 REM Check for existence of one lib, even though we should check for all results
311 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
313 echo glslang 64-bit Debug build failed!
316 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
317 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
319 REM Check for existence of one lib, even though we should check for all results
320 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
322 echo glslang 64-bit Release build failed!
329 echo Building %SPIRV_TOOLS_DIR%
332 REM Cleanup any old directories lying around.
340 echo Making 32-bit spirv-tools
341 echo *************************
343 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build32
345 cd %SPIRV_TOOLS_BUILD_DIR%
347 echo Generating 32-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
348 cmake -G "Visual Studio %VS_VERSION%" ..
350 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug
351 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
353 REM Check for existence of one lib, even though we should check for all results
354 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
356 echo spirv-tools 32-bit Debug build failed!
360 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release
361 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
363 REM Check for existence of one lib, even though we should check for all results
364 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
366 echo spirv-tools 32-bit Release build failed!
372 echo Making 64-bit spirv-tools
373 echo *************************
375 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build
376 cd %SPIRV_TOOLS_BUILD_DIR%
378 echo Generating 64-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
379 cmake -G "Visual Studio %VS_VERSION% Win64" ..
381 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug
382 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
384 REM Check for existence of one lib, even though we should check for all results
385 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
387 echo spirv-tools 64-bit Debug build failed!
391 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release
392 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
394 REM Check for existence of one lib, even though we should check for all results
395 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
397 echo spirv-tools 64-bit Release build failed!