blob: 237f7757738c12c1e7cf1927be13513a92977fc0 [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
Mike Weiblen22489252017-02-16 17:00:35 -070031 echo --all sync and build glslang, spirv-tools
Mark Lobodzinski0e393752016-05-04 09:19:54 -060032 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
Mike Weiblen22489252017-02-16 17:00:35 -0700125if not exist %REVISION_DIR%\glslang_giturl (
126 echo.
127 echo Missing glslang_giturl file! Place it in %REVISION_DIR% with git repo URL in it.
128 set errorCode=1
129 goto:error
130)
131
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700132if not exist %REVISION_DIR%\glslang_revision (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600133 echo.
Mike Weiblen22489252017-02-16 17:00:35 -0700134 echo Missing glslang_revision file! Place it in %REVISION_DIR% with target version in it.
135 set errorCode=1
136 goto:error
137)
138
139if not exist %REVISION_DIR%\spirv-tools_giturl (
140 echo.
141 echo Missing spirv-tools_giturl file! Place it in %REVISION_DIR% with git repo URL in it.
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600142 set errorCode=1
143 goto:error
144)
145
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700146if not exist %REVISION_DIR%\spirv-tools_revision (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600147 echo.
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700148 echo Missing spirv-tools_revision file! Place it in %REVISION_DIR% with target version in it.
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600149 set errorCode=1
150 goto:error
151)
152
Mike Weiblen22489252017-02-16 17:00:35 -0700153if not exist %REVISION_DIR%\spirv-headers_giturl (
154 echo.
155 echo Missing spirv-headers_giturl file! Place it in %REVISION_DIR% with git repo URL in it.
156 set errorCode=1
157 goto:error
158)
159
Mark Lobodzinski39421252016-11-18 13:48:44 -0700160if not exist %REVISION_DIR%\spirv-headers_revision (
161 echo.
162 echo Missing spirv-headers_revision file! Place it in %REVISION_DIR% with target version in it.
163 set errorCode=1
164 goto:error
165)
166
Mike Weiblen22489252017-02-16 17:00:35 -0700167set /p GLSLANG_GITURL= < %REVISION_DIR%\glslang_giturl
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700168set /p GLSLANG_REVISION= < %REVISION_DIR%\glslang_revision
Mike Weiblen22489252017-02-16 17:00:35 -0700169set /p SPIRV_TOOLS_GITURL= < %REVISION_DIR%\spirv-tools_giturl
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700170set /p SPIRV_TOOLS_REVISION= < %REVISION_DIR%\spirv-tools_revision
Mike Weiblen22489252017-02-16 17:00:35 -0700171set /p SPIRV_HEADERS_GITURL= < %REVISION_DIR%\spirv-headers_giturl
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700172set /p SPIRV_HEADERS_REVISION= < %REVISION_DIR%\spirv-headers_revision
Mike Weiblen22489252017-02-16 17:00:35 -0700173
174echo GLSLANG_GITURL=%GLSLANG_GITURL%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600175echo GLSLANG_REVISION=%GLSLANG_REVISION%
Mike Weiblen22489252017-02-16 17:00:35 -0700176echo SPIRV_TOOLS_GITURL=%SPIRV_TOOLS_GITURL%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600177echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
Mike Weiblen22489252017-02-16 17:00:35 -0700178echo SPIRV_HEADERS_GITURL=%SPIRV_HEADERS_GITURL%
Mark Young12238372016-08-11 08:46:55 -0600179echo SPIRV_HEADERS_REVISION=%SPIRV_HEADERS_REVISION%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600180
181
182echo Creating and/or updating glslang, spirv-tools in %BASE_DIR%
183
184if %sync-glslang% equ 1 (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600185 if not exist %GLSLANG_DIR% (
186 call:create_glslang
187 )
188 if %errorCode% neq 0 (goto:error)
189 call:update_glslang
190 if %errorCode% neq 0 (goto:error)
191)
192
193if %sync-spirv-tools% equ 1 (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600194 if %errorlevel% neq 0 (goto:error)
195 if not exist %SPIRV_TOOLS_DIR% (
196 call:create_spirv-tools
197 )
198 if %errorCode% neq 0 (goto:error)
199 call:update_spirv-tools
200 if %errorCode% neq 0 (goto:error)
201)
202
203if %build-glslang% equ 1 (
204 call:build_glslang
205 if %errorCode% neq 0 (goto:error)
206)
207
208if %build-spirv-tools% equ 1 (
209 call:build_spirv-tools
210 if %errorCode% neq 0 (goto:error)
211)
212
213echo.
214echo Exiting
215goto:finish
216
217:error
218echo.
219echo Halting due to error
220goto:finish
221
222:finish
223if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
224endlocal
225goto:eof
226
227
228
229REM // ======== Functions ======== //
230
231:create_glslang
232 echo.
233 echo Creating local glslang repository %GLSLANG_DIR%)
234 mkdir %GLSLANG_DIR%
235 cd %GLSLANG_DIR%
Mike Weiblen22489252017-02-16 17:00:35 -0700236 git clone %GLSLANG_GITURL% .
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600237 git checkout %GLSLANG_REVISION%
238 if not exist %GLSLANG_DIR%\SPIRV (
239 echo glslang source download failed!
240 set errorCode=1
241 )
242goto:eof
243
244:update_glslang
245 echo.
246 echo Updating %GLSLANG_DIR%
247 cd %GLSLANG_DIR%
248 git fetch --all
249 git checkout %GLSLANG_REVISION%
250goto:eof
251
252:create_spirv-tools
253 echo.
254 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%)
255 mkdir %SPIRV_TOOLS_DIR%
256 cd %SPIRV_TOOLS_DIR%
Mike Weiblen22489252017-02-16 17:00:35 -0700257 git clone %SPIRV_TOOLS_GITURL% .
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600258 git checkout %SPIRV_TOOLS_REVISION%
259 if not exist %SPIRV_TOOLS_DIR%\source (
260 echo spirv-tools source download failed!
261 set errorCode=1
262 )
Greg Fischer04d0a562016-06-17 12:19:46 -0600263 mkdir %SPIRV_TOOLS_DIR%\external
264 mkdir %SPIRV_TOOLS_DIR%\external\spirv-headers
265 cd %SPIRV_TOOLS_DIR%\external\spirv-headers
Mike Weiblen22489252017-02-16 17:00:35 -0700266 git clone %SPIRV_HEADERS_GITURL% .
Mark Young12238372016-08-11 08:46:55 -0600267 git checkout %SPIRV_HEADERS_REVISION%
Greg Fischer04d0a562016-06-17 12:19:46 -0600268 if not exist %SPIRV_TOOLS_DIR%\external\spirv-headers\README.md (
269 echo spirv-headers download failed!
270 set errorCode=1
271 )
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600272goto:eof
Mark Young1ef23302016-01-13 13:47:16 -0700273
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600274:update_spirv-tools
275 echo.
276 echo Updating %SPIRV_TOOLS_DIR%
277 cd %SPIRV_TOOLS_DIR%
278 git fetch --all
279 git checkout %SPIRV_TOOLS_REVISION%
Greg Fischer04d0a562016-06-17 12:19:46 -0600280 cd %SPIRV_TOOLS_DIR%\external\spirv-headers
281 git fetch --all
Mark Young12238372016-08-11 08:46:55 -0600282 git checkout %SPIRV_HEADERS_REVISION%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600283goto:eof
Mark Youngc2f10212016-01-13 13:47:16 -0700284
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600285:build_glslang
286 echo.
287 echo Building %GLSLANG_DIR%
288 cd %GLSLANG_DIR%
Lenny Komow3b62ce82016-11-29 14:24:39 -0700289
290 if not exist build32 (
291 mkdir build32
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600292 )
Lenny Komow3b62ce82016-11-29 14:24:39 -0700293 if not exist build (
294 mkdir build
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600295 )
296
297 echo Making 32-bit glslang
298 echo *************************
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600299 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32
300 cd %GLSLANG_BUILD_DIR%
301
302 echo Generating 32-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
303 cmake -G "Visual Studio %VS_VERSION%" -DCMAKE_INSTALL_PREFIX=install ..
304
305 echo Building 32-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug
306 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
307
308 REM Check for existence of one lib, even though we should check for all results
Karl Schultz168a62b2016-07-18 09:40:37 -0600309 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600310 echo.
311 echo glslang 32-bit Debug build failed!
312 set errorCode=1
313 )
314 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release
315 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
316
317 REM Check for existence of one lib, even though we should check for all results
318 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
319 echo.
320 echo glslang 32-bit Release build failed!
321 set errorCode=1
322 )
323
324 cd ..
325
326 echo Making 64-bit glslang
327 echo *************************
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600328 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
329 cd %GLSLANG_BUILD_DIR%
330
331 echo Generating 64-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
332 cmake -G "Visual Studio %VS_VERSION% Win64" -DCMAKE_INSTALL_PREFIX=install ..
333
334 echo Building 64-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
335 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
336
337 REM Check for existence of one lib, even though we should check for all results
Karl Schultz168a62b2016-07-18 09:40:37 -0600338 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600339 echo.
340 echo glslang 64-bit Debug build failed!
341 set errorCode=1
342 )
343 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
344 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
345
346 REM Check for existence of one lib, even though we should check for all results
347 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
348 echo.
349 echo glslang 64-bit Release build failed!
350 set errorCode=1
351 )
352goto:eof
353
354:build_spirv-tools
355 echo.
356 echo Building %SPIRV_TOOLS_DIR%
357 cd %SPIRV_TOOLS_DIR%
358
359 REM Cleanup any old directories lying around.
Lenny Komow3b62ce82016-11-29 14:24:39 -0700360 if not exist build32 (
361 mkdir build32
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600362 )
Lenny Komow3b62ce82016-11-29 14:24:39 -0700363 if not exist build (
364 mkdir build
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600365 )
366
367 echo Making 32-bit spirv-tools
368 echo *************************
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600369 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build32
370
371 cd %SPIRV_TOOLS_BUILD_DIR%
372
373 echo Generating 32-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
374 cmake -G "Visual Studio %VS_VERSION%" ..
375
376 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug
377 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
378
379 REM Check for existence of one lib, even though we should check for all results
380 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
381 echo.
382 echo spirv-tools 32-bit Debug build failed!
383 set errorCode=1
384 )
385
386 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release
387 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
388
389 REM Check for existence of one lib, even though we should check for all results
390 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
391 echo.
392 echo spirv-tools 32-bit Release build failed!
393 set errorCode=1
394 )
395
396 cd ..
397
398 echo Making 64-bit spirv-tools
399 echo *************************
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600400 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build
401 cd %SPIRV_TOOLS_BUILD_DIR%
402
403 echo Generating 64-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
404 cmake -G "Visual Studio %VS_VERSION% Win64" ..
405
406 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug
407 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
408
409 REM Check for existence of one lib, even though we should check for all results
410 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
411 echo.
412 echo spirv-tools 64-bit Debug build failed!
413 set errorCode=1
414 )
415
416 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release
417 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
418
419 REM Check for existence of one lib, even though we should check for all results
420 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
421 echo.
422 echo spirv-tools 64-bit Release build failed!
423 set errorCode=1
424 )
425goto:eof