blob: b72d7bc6974bf279c283ddbd8505b04f7126517f [file] [log] [blame]
Mark Lobodzinski0e393752016-05-04 09:19:54 -06001@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
Jon Ashburn17c64682016-05-02 08:39:14 -060016set BASE_DIR=%BUILD_DIR%external
Mark Lobodzinski0e393752016-05-04 09:19:54 -060017set 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%
Karl Schultzdb27d512016-07-07 10:41:25 -0600218 REM Special case for this particular revision:
219 REM Pull in a patch that fixes a compilation issue with g++ 5.3
220 REM See https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/681
221 if "%GLSLANG_REVISION%" == "4678ca9dacfec7a084dbc69bbe568bdad6889f1b" (
222 git checkout %GLSLANG_REVISION% -B temp1610
223 git cherry-pick 880bf36cacee1cfce7d5d94991eb18c9e2d59d39
224 )
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600225goto:eof
226
227:create_spirv-tools
228 echo.
229 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%)
230 mkdir %SPIRV_TOOLS_DIR%
231 cd %SPIRV_TOOLS_DIR%
Peter Lohrmann18c06a22016-02-16 15:20:58 -0800232 git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600233 git checkout %SPIRV_TOOLS_REVISION%
234 if not exist %SPIRV_TOOLS_DIR%\source (
235 echo spirv-tools source download failed!
236 set errorCode=1
237 )
Greg Fischer04d0a562016-06-17 12:19:46 -0600238 mkdir %SPIRV_TOOLS_DIR%\external
239 mkdir %SPIRV_TOOLS_DIR%\external\spirv-headers
240 cd %SPIRV_TOOLS_DIR%\external\spirv-headers
241 git clone https://github.com/KhronosGroup/SPIRV-HEADERS.git .
242 if not exist %SPIRV_TOOLS_DIR%\external\spirv-headers\README.md (
243 echo spirv-headers download failed!
244 set errorCode=1
245 )
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600246goto:eof
Mark Young1ef23302016-01-13 13:47:16 -0700247
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600248:update_spirv-tools
249 echo.
250 echo Updating %SPIRV_TOOLS_DIR%
251 cd %SPIRV_TOOLS_DIR%
252 git fetch --all
253 git checkout %SPIRV_TOOLS_REVISION%
Greg Fischer04d0a562016-06-17 12:19:46 -0600254 if not exist %SPIRV_TOOLS_DIR%\external\spirv-headers\README.md (
255 mkdir %SPIRV_TOOLS_DIR%\external
256 mkdir %SPIRV_TOOLS_DIR%\external\spirv-headers
257 cd %SPIRV_TOOLS_DIR%\external\spirv-headers
258 git clone https://github.com/KhronosGroup/SPIRV-HEADERS.git .
259 goto:eof
260 )
261 cd %SPIRV_TOOLS_DIR%\external\spirv-headers
262 git fetch --all
263 git pull
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600264goto:eof
Mark Youngc2f10212016-01-13 13:47:16 -0700265
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600266:build_glslang
267 echo.
268 echo Building %GLSLANG_DIR%
269 cd %GLSLANG_DIR%
270
271 REM Cleanup any old directories lying around.
272 if exist build32 (
273 rmdir /s /q build32
274 )
275 if exist build (
276 rmdir /s /q build
277 )
278
279 echo Making 32-bit glslang
280 echo *************************
281 mkdir build32
282 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32
283 cd %GLSLANG_BUILD_DIR%
284
285 echo Generating 32-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
286 cmake -G "Visual Studio %VS_VERSION%" -DCMAKE_INSTALL_PREFIX=install ..
287
288 echo Building 32-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug
289 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
290
291 REM Check for existence of one lib, even though we should check for all results
292 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslang.lib (
293 echo.
294 echo glslang 32-bit Debug build failed!
295 set errorCode=1
296 )
297 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release
298 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
299
300 REM Check for existence of one lib, even though we should check for all results
301 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
302 echo.
303 echo glslang 32-bit Release build failed!
304 set errorCode=1
305 )
306
307 cd ..
308
309 echo Making 64-bit glslang
310 echo *************************
311 mkdir build
312 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
313 cd %GLSLANG_BUILD_DIR%
314
315 echo Generating 64-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
316 cmake -G "Visual Studio %VS_VERSION% Win64" -DCMAKE_INSTALL_PREFIX=install ..
317
318 echo Building 64-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
319 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
320
321 REM Check for existence of one lib, even though we should check for all results
322 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslang.lib (
323 echo.
324 echo glslang 64-bit Debug build failed!
325 set errorCode=1
326 )
327 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
328 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
329
330 REM Check for existence of one lib, even though we should check for all results
331 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
332 echo.
333 echo glslang 64-bit Release build failed!
334 set errorCode=1
335 )
336goto:eof
337
338:build_spirv-tools
339 echo.
340 echo Building %SPIRV_TOOLS_DIR%
341 cd %SPIRV_TOOLS_DIR%
342
343 REM Cleanup any old directories lying around.
344 if exist build32 (
345 rmdir /s /q build32
346 )
347 if exist build (
348 rmdir /s /q build
349 )
350
351 echo Making 32-bit spirv-tools
352 echo *************************
353 mkdir build32
354 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build32
355
356 cd %SPIRV_TOOLS_BUILD_DIR%
357
358 echo Generating 32-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
359 cmake -G "Visual Studio %VS_VERSION%" ..
360
361 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug
362 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
363
364 REM Check for existence of one lib, even though we should check for all results
365 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
366 echo.
367 echo spirv-tools 32-bit Debug build failed!
368 set errorCode=1
369 )
370
371 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release
372 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
373
374 REM Check for existence of one lib, even though we should check for all results
375 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
376 echo.
377 echo spirv-tools 32-bit Release build failed!
378 set errorCode=1
379 )
380
381 cd ..
382
383 echo Making 64-bit spirv-tools
384 echo *************************
385 mkdir build
386 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build
387 cd %SPIRV_TOOLS_BUILD_DIR%
388
389 echo Generating 64-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
390 cmake -G "Visual Studio %VS_VERSION% Win64" ..
391
392 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug
393 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
394
395 REM Check for existence of one lib, even though we should check for all results
396 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
397 echo.
398 echo spirv-tools 64-bit Debug build failed!
399 set errorCode=1
400 )
401
402 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release
403 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
404
405 REM Check for existence of one lib, even though we should check for all results
406 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
407 echo.
408 echo spirv-tools 64-bit Release build failed!
409 set errorCode=1
410 )
411goto:eof