blob: 91b49ecae5bce1ef3b0dc0d813ba153042624423 [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
Mark Lobodzinski6cde2f02016-11-18 14:12:01 -07006python .\scripts\determine_vs_version.py > vsversion.tmp
Mark Lobodzinski0e393752016-05-04 09:19:54 -06007set /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
Karl Schultzece13962016-09-27 18:38:02 -060016set BASE_DIR="%BUILD_DIR%external"
Mark Lobodzinski1e4da612016-11-18 13:20:36 -070017set REVISION_DIR="%BUILD_DIR%external_revisions"
Mark Lobodzinski0e393752016-05-04 09:19:54 -060018set GLSLANG_DIR=%BASE_DIR%\glslang
19set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools
20
21REM // ======== Parameter parsing ======== //
22
23 if "%1" == "" (
24 echo usage: update_external_sources.bat [options]
25 echo.
26 echo Available options:
27 echo --sync-glslang just pull glslang_revision
28 echo --sync-spirv-tools just pull spirv-tools_revision
29 echo --build-glslang pulls glslang_revision, configures CMake, builds Release and Debug
30 echo --build-spirv-tools pulls spirv-tools_revision, configures CMake, builds Release and Debug
31 echo --all sync and build glslang, LunarGLASS, spirv-tools
32 goto:finish
33 )
34
35 set sync-glslang=0
36 set sync-spirv-tools=0
37 set build-glslang=0
38 set build-spirv-tools=0
39 set check-glslang-build-dependencies=0
40
41 :parameterLoop
42
43 if "%1"=="" goto:parameterContinue
44
45 if "%1" == "--sync-glslang" (
46 set sync-glslang=1
47 shift
48 goto:parameterLoop
49 )
50
51 if "%1" == "--sync-spirv-tools" (
52 set sync-spirv-tools=1
53 shift
54 goto:parameterLoop
55 )
56
57 if "%1" == "--build-glslang" (
58 set sync-glslang=1
59 set check-glslang-build-dependencies=1
60 set build-glslang=1
61 shift
62 goto:parameterLoop
63 )
64
65 if "%1" == "--build-spirv-tools" (
66 set sync-spirv-tools=1
67 REM glslang has the same needs as spirv-tools
68 set check-glslang-build-dependencies=1
69 set build-spirv-tools=1
70 shift
71 goto:parameterLoop
72 )
73
74 if "%1" == "--all" (
75 set sync-glslang=1
76 set sync-spirv-tools=1
77 set build-glslang=1
78 set build-spirv-tools=1
79 set check-glslang-build-dependencies=1
80 shift
81 goto:parameterLoop
82 )
83
84 echo Unrecognized options "%1"
85 goto:error
86
87 :parameterContinue
88
89REM // ======== end Parameter parsing ======== //
90
91
92REM // ======== Dependency checking ======== //
93 REM git is required for all paths
94 for %%X in (git.exe) do (set FOUND=%%~$PATH:X)
95 if not defined FOUND (
96 echo Dependency check failed:
97 echo git.exe not found
98 echo Git for Windows can be downloaded here: https://git-scm.com/download/win
99 echo Install and ensure git.exe makes it into your PATH
100 set errorCode=1
101 )
102
103 if %check-glslang-build-dependencies% equ 1 (
104 for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)
105 if not defined FOUND (
106 echo Dependency check failed:
107 echo cmake.exe not found
108 echo Get CNake 2.8 for Windows here: http://www.cmake.org/cmake/resources/software.html
109 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"
110 set errorCode=1
111 )
112 )
113
114
115 REM goto:main
116
117REM // ======== end Dependency checking ======== //
118
119:main
120
121if %errorCode% neq 0 (goto:error)
122
123REM Read the target versions from external file, which is shared with Linux script
124
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700125if not exist %REVISION_DIR%\glslang_revision (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600126 echo.
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700127 echo Missing glslang_revision file! Place it in %REVSION_DIR% with target version in it.
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600128 set errorCode=1
129 goto:error
130)
131
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700132if not exist %REVISION_DIR%\spirv-tools_revision (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600133 echo.
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700134 echo Missing spirv-tools_revision file! Place it in %REVISION_DIR% with target version in it.
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600135 set errorCode=1
136 goto:error
137)
138
Mark Lobodzinski39421252016-11-18 13:48:44 -0700139if not exist %REVISION_DIR%\spirv-headers_revision (
140 echo.
141 echo Missing spirv-headers_revision file! Place it in %REVISION_DIR% with target version in it.
142 set errorCode=1
143 goto:error
144)
145
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700146set /p GLSLANG_REVISION= < %REVISION_DIR%\glslang_revision
147set /p SPIRV_TOOLS_REVISION= < %REVISION_DIR%\spirv-tools_revision
148set /p SPIRV_HEADERS_REVISION= < %REVISION_DIR%\spirv-headers_revision
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600149echo GLSLANG_REVISION=%GLSLANG_REVISION%
150echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
Mark Young12238372016-08-11 08:46:55 -0600151echo SPIRV_HEADERS_REVISION=%SPIRV_HEADERS_REVISION%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600152
153
154echo Creating and/or updating glslang, spirv-tools in %BASE_DIR%
155
156if %sync-glslang% equ 1 (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600157 if not exist %GLSLANG_DIR% (
158 call:create_glslang
159 )
160 if %errorCode% neq 0 (goto:error)
161 call:update_glslang
162 if %errorCode% neq 0 (goto:error)
163)
164
165if %sync-spirv-tools% equ 1 (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600166 if %errorlevel% neq 0 (goto:error)
167 if not exist %SPIRV_TOOLS_DIR% (
168 call:create_spirv-tools
169 )
170 if %errorCode% neq 0 (goto:error)
171 call:update_spirv-tools
172 if %errorCode% neq 0 (goto:error)
173)
174
175if %build-glslang% equ 1 (
176 call:build_glslang
177 if %errorCode% neq 0 (goto:error)
178)
179
180if %build-spirv-tools% equ 1 (
181 call:build_spirv-tools
182 if %errorCode% neq 0 (goto:error)
183)
184
185echo.
186echo Exiting
187goto:finish
188
189:error
190echo.
191echo Halting due to error
192goto:finish
193
194:finish
195if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
196endlocal
197goto:eof
198
199
200
201REM // ======== Functions ======== //
202
203:create_glslang
204 echo.
205 echo Creating local glslang repository %GLSLANG_DIR%)
206 mkdir %GLSLANG_DIR%
207 cd %GLSLANG_DIR%
208 git clone https://github.com/KhronosGroup/glslang.git .
209 git checkout %GLSLANG_REVISION%
210 if not exist %GLSLANG_DIR%\SPIRV (
211 echo glslang source download failed!
212 set errorCode=1
213 )
214goto:eof
215
216:update_glslang
217 echo.
218 echo Updating %GLSLANG_DIR%
219 cd %GLSLANG_DIR%
220 git fetch --all
221 git checkout %GLSLANG_REVISION%
222goto:eof
223
224:create_spirv-tools
225 echo.
226 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%)
227 mkdir %SPIRV_TOOLS_DIR%
228 cd %SPIRV_TOOLS_DIR%
Peter Lohrmann18c06a22016-02-16 15:20:58 -0800229 git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600230 git checkout %SPIRV_TOOLS_REVISION%
231 if not exist %SPIRV_TOOLS_DIR%\source (
232 echo spirv-tools source download failed!
233 set errorCode=1
234 )
Greg Fischer04d0a562016-06-17 12:19:46 -0600235 mkdir %SPIRV_TOOLS_DIR%\external
236 mkdir %SPIRV_TOOLS_DIR%\external\spirv-headers
237 cd %SPIRV_TOOLS_DIR%\external\spirv-headers
238 git clone https://github.com/KhronosGroup/SPIRV-HEADERS.git .
Mark Young12238372016-08-11 08:46:55 -0600239 git checkout %SPIRV_HEADERS_REVISION%
Greg Fischer04d0a562016-06-17 12:19:46 -0600240 if not exist %SPIRV_TOOLS_DIR%\external\spirv-headers\README.md (
241 echo spirv-headers download failed!
242 set errorCode=1
243 )
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600244goto:eof
Mark Young1ef23302016-01-13 13:47:16 -0700245
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600246:update_spirv-tools
247 echo.
248 echo Updating %SPIRV_TOOLS_DIR%
249 cd %SPIRV_TOOLS_DIR%
250 git fetch --all
251 git checkout %SPIRV_TOOLS_REVISION%
Greg Fischer04d0a562016-06-17 12:19:46 -0600252 cd %SPIRV_TOOLS_DIR%\external\spirv-headers
253 git fetch --all
Mark Young12238372016-08-11 08:46:55 -0600254 git checkout %SPIRV_HEADERS_REVISION%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600255goto:eof
Mark Youngc2f10212016-01-13 13:47:16 -0700256
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600257:build_glslang
258 echo.
259 echo Building %GLSLANG_DIR%
260 cd %GLSLANG_DIR%
Lenny Komow3b62ce82016-11-29 14:24:39 -0700261
262 if not exist build32 (
263 mkdir build32
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600264 )
Lenny Komow3b62ce82016-11-29 14:24:39 -0700265 if not exist build (
266 mkdir build
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600267 )
268
269 echo Making 32-bit glslang
270 echo *************************
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600271 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32
272 cd %GLSLANG_BUILD_DIR%
273
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 ..
276
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
279
280 REM Check for existence of one lib, even though we should check for all results
Karl Schultz168a62b2016-07-18 09:40:37 -0600281 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600282 echo.
283 echo glslang 32-bit Debug build failed!
284 set errorCode=1
285 )
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
288
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 (
291 echo.
292 echo glslang 32-bit Release build failed!
293 set errorCode=1
294 )
295
296 cd ..
297
298 echo Making 64-bit glslang
299 echo *************************
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600300 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
301 cd %GLSLANG_BUILD_DIR%
302
303 echo Generating 64-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
304 cmake -G "Visual Studio %VS_VERSION% Win64" -DCMAKE_INSTALL_PREFIX=install ..
305
306 echo Building 64-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
307 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
308
309 REM Check for existence of one lib, even though we should check for all results
Karl Schultz168a62b2016-07-18 09:40:37 -0600310 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600311 echo.
312 echo glslang 64-bit Debug build failed!
313 set errorCode=1
314 )
315 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
316 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
317
318 REM Check for existence of one lib, even though we should check for all results
319 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
320 echo.
321 echo glslang 64-bit Release build failed!
322 set errorCode=1
323 )
324goto:eof
325
326:build_spirv-tools
327 echo.
328 echo Building %SPIRV_TOOLS_DIR%
329 cd %SPIRV_TOOLS_DIR%
330
331 REM Cleanup any old directories lying around.
Lenny Komow3b62ce82016-11-29 14:24:39 -0700332 if not exist build32 (
333 mkdir build32
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600334 )
Lenny Komow3b62ce82016-11-29 14:24:39 -0700335 if not exist build (
336 mkdir build
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600337 )
338
339 echo Making 32-bit spirv-tools
340 echo *************************
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600341 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build32
342
343 cd %SPIRV_TOOLS_BUILD_DIR%
344
345 echo Generating 32-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
346 cmake -G "Visual Studio %VS_VERSION%" ..
347
348 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug
349 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
350
351 REM Check for existence of one lib, even though we should check for all results
352 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
353 echo.
354 echo spirv-tools 32-bit Debug build failed!
355 set errorCode=1
356 )
357
358 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release
359 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
360
361 REM Check for existence of one lib, even though we should check for all results
362 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
363 echo.
364 echo spirv-tools 32-bit Release build failed!
365 set errorCode=1
366 )
367
368 cd ..
369
370 echo Making 64-bit spirv-tools
371 echo *************************
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600372 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build
373 cd %SPIRV_TOOLS_BUILD_DIR%
374
375 echo Generating 64-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
376 cmake -G "Visual Studio %VS_VERSION% Win64" ..
377
378 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug
379 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
380
381 REM Check for existence of one lib, even though we should check for all results
382 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
383 echo.
384 echo spirv-tools 64-bit Debug build failed!
385 set errorCode=1
386 )
387
388 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release
389 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
390
391 REM Check for existence of one lib, even though we should check for all results
392 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
393 echo.
394 echo spirv-tools 64-bit Release build failed!
395 set errorCode=1
396 )
397goto:eof