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 echo GLSLANG_REVISION=%GLSLANG_REVISION%
141 echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
144 echo Creating and/or updating glslang, spirv-tools in %BASE_DIR%
146 if %sync-glslang% equ 1 (
147 if exist %GLSLANG_DIR% (
148 rd /S /Q %GLSLANG_DIR%
150 if not exist %GLSLANG_DIR% (
153 if %errorCode% neq 0 (goto:error)
155 if %errorCode% neq 0 (goto:error)
158 if %sync-spirv-tools% equ 1 (
159 if exist %SPIRV_TOOLS_DIR% (
160 rd /S /Q %SPIRV_TOOLS_DIR%
162 if %errorlevel% neq 0 (goto:error)
163 if not exist %SPIRV_TOOLS_DIR% (
164 call:create_spirv-tools
166 if %errorCode% neq 0 (goto:error)
167 call:update_spirv-tools
168 if %errorCode% neq 0 (goto:error)
171 if %build-glslang% equ 1 (
173 if %errorCode% neq 0 (goto:error)
176 if %build-spirv-tools% equ 1 (
177 call:build_spirv-tools
178 if %errorCode% neq 0 (goto:error)
187 echo Halting due to error
191 if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
197 REM // ======== Functions ======== //
201 echo Creating local glslang repository %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!
214 echo Updating %GLSLANG_DIR%
217 git checkout %GLSLANG_REVISION%
222 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%)
223 mkdir %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!
235 echo Updating %SPIRV_TOOLS_DIR%
238 git checkout %SPIRV_TOOLS_REVISION%
243 echo Building %GLSLANG_DIR%
246 REM Cleanup any old directories lying around.
254 echo Making 32-bit glslang
255 echo *************************
257 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32
258 cd %GLSLANG_BUILD_DIR%
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 ..
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
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 (
269 echo glslang 32-bit Debug build failed!
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
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 (
278 echo glslang 32-bit Release build failed!
284 echo Making 64-bit glslang
285 echo *************************
287 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
288 cd %GLSLANG_BUILD_DIR%
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 ..
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
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 (
299 echo glslang 64-bit Debug build failed!
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
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 (
308 echo glslang 64-bit Release build failed!
315 echo Building %SPIRV_TOOLS_DIR%
318 REM Cleanup any old directories lying around.
326 echo Making 32-bit spirv-tools
327 echo *************************
329 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build32
331 cd %SPIRV_TOOLS_BUILD_DIR%
333 echo Generating 32-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
334 cmake -G "Visual Studio %VS_VERSION%" ..
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
339 REM Check for existence of one lib, even though we should check for all results
340 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
342 echo spirv-tools 32-bit Debug build failed!
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
349 REM Check for existence of one lib, even though we should check for all results
350 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
352 echo spirv-tools 32-bit Release build failed!
358 echo Making 64-bit spirv-tools
359 echo *************************
361 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build
362 cd %SPIRV_TOOLS_BUILD_DIR%
364 echo Generating 64-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
365 cmake -G "Visual Studio %VS_VERSION% Win64" ..
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
370 REM Check for existence of one lib, even though we should check for all results
371 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
373 echo spirv-tools 64-bit Debug build failed!
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
380 REM Check for existence of one lib, even though we should check for all results
381 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
383 echo spirv-tools 64-bit Release build failed!