blob: d4ac865a8077766230836a36fc01ac0eabcec73f [file] [log] [blame]
Mark Lobodzinski0e393752016-05-04 09:19:54 -06001@echo off
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -07002REM Update source for glslang
Mark Lobodzinski0e393752016-05-04 09:19:54 -06003
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
Karl Schultz0e417132018-01-03 12:50:46 -070019set do_32=0
20set do_64=0
21set do_debug=0
22set do_release=0
Mark Lobodzinski0e393752016-05-04 09:19:54 -060023
24REM // ======== Parameter parsing ======== //
25
Jeff Juliano6c1422c2017-08-26 10:04:29 -040026 set arg-use-implicit-component-list=1
27 set arg-do-glslang=0
Jeff Juliano6c1422c2017-08-26 10:04:29 -040028 set arg-no-sync=0
29 set arg-no-build=0
Karl Schultz0e417132018-01-03 12:50:46 -070030 set arg-32=0
31 set arg-64=0
32 set arg-debug=0
33 set arg-release=0
Jeff Juliano6c1422c2017-08-26 10:04:29 -040034
35 :parameterLoop
36
37 if "%1"=="" goto:parameterContinue
38
39 if "%1" == "--glslang" (
40 set arg-do-glslang=1
41 set arg-use-implicit-component-list=0
42 echo Building glslang ^(%1^)
43 shift
44 goto:parameterLoop
45 )
46
47 if "%1" == "-g" (
48 set arg-do-glslang=1
49 set arg-use-implicit-component-list=0
50 echo Building glslang ^(%1^)
51 shift
52 goto:parameterLoop
53 )
54
Jeff Juliano6c1422c2017-08-26 10:04:29 -040055 if "%1" == "--no-sync" (
56 set arg-no-sync=1
57 echo Skipping sync ^(%1^)
58 shift
59 goto:parameterLoop
60 )
61
62 if "%1" == "--no-build" (
63 set arg-no-build=1
64 echo Skipping build ^(%1^)
65 shift
66 goto:parameterLoop
67 )
68
Karl Schultz0e417132018-01-03 12:50:46 -070069 if "%1" == "--32" (
70 set arg-32=1
71 echo 32-bit build requested
72 shift
73 goto:parameterLoop
74 )
75
76 if "%1" == "--64" (
77 set arg-64=1
78 echo 64-bit build requested
79 shift
80 goto:parameterLoop
81 )
82
83 if "%1" == "--debug" (
84 set arg-debug=1
85 echo debug build requested
86 shift
87 goto:parameterLoop
88 )
89
90 if "%1" == "--release" (
91 set arg-release=1
92 echo release build requested
93 shift
94 goto:parameterLoop
95 )
96
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -070097 if "%1" == "--spirv-tools" (
98 echo --spirv-tools argument has been deprecated and is no longer necessary
99 shift
100 goto:parameterLoop
101 )
102
103 if "%1" == "-s" (
104 echo --s argument has been deprecated and is no longer necessary
105 shift
106 goto:parameterLoop
107 )
108
109 if "%1" == "--all" (
110 echo --all argument has been deprecated and is no longer necessary
111 set arg-do-glslang=1
112 set arg-use-implicit-component-list=0
113 echo Building glslang ^(%1^)
114 shift
115 goto:parameterLoop
116 )
117
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400118 echo.
119 echo Unrecognized option "%1"
120 echo.
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600121 echo usage: update_external_sources.bat [options]
122 echo.
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400123 echo Available options:
124 echo -g ^| --glslang enable glslang component
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400125 echo --all enable all components
126 echo --no-sync skip sync from git
127 echo --no-build skip build
Karl Schultz0e417132018-01-03 12:50:46 -0700128 echo --32 build for 32-bit
129 echo --64 build for 64-bit
130 echo --debug build for debug
131 echo --release build for release
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400132 echo.
Jeff Juliano3bedf342017-08-26 10:22:22 -0400133 echo If any component enables are provided, only those components are enabled.
134 echo If no component enables are provided, all components are enabled.
135 echo.
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400136 echo Sync uses git to pull a specific revision.
137 echo Build configures CMake, builds Release and Debug.
Karl Schultz0e417132018-01-03 12:50:46 -0700138 echo.
139 echo --32 without --64 builds only 32-bit, and vice-versa.
140 echo --debug without --release builds only debug, and vice-versa.
141 echo Specifying neither or both --32 and --64 builds both.
142 echo Specifying neither or both --debug and --release builds both.
143 echo So specifying none of these 4 options (default) builds all 4.
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400144
Jeff Juliano3bedf342017-08-26 10:22:22 -0400145
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400146 goto:error
147
148 :parameterContinue
149
150 if %arg-use-implicit-component-list% equ 1 (
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700151 echo Building glslang
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400152 set arg-do-glslang=1
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600153 )
154
155 set sync-glslang=0
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600156 set build-glslang=0
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600157 set check-glslang-build-dependencies=0
158
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400159 if %arg-do-glslang% equ 1 (
160 if %arg-no-sync% equ 0 (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600161 set sync-glslang=1
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600162 )
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400163 if %arg-no-build% equ 0 (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600164 set check-glslang-build-dependencies=1
165 set build-glslang=1
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600166 )
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400167 )
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600168
Karl Schultz0e417132018-01-03 12:50:46 -0700169 if %arg-32% equ 1 (
170 set do_32=1
171 )
172 if %arg-64% equ 1 (
173 set do_64=1
174 )
175 if %arg-32% equ 0 (
176 if %arg-64% equ 0 (
177 set do_32=1
178 set do_64=1
179 )
180 )
181
182 if %arg-debug% equ 1 (
183 set do_debug=1
184 )
185 if %arg-release% equ 1 (
186 set do_release=1
187 )
188 if %arg-debug% equ 0 (
189 if %arg-release% equ 0 (
190 set do_debug=1
191 set do_release=1
192 )
193 )
194
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400195 REM this is a debugging aid that can be enabled while debugging command-line parsing
196 if 0 equ 1 (
197 set arg
198 set sync-glslang
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400199 set build-glslang
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400200 set check-glslang-build-dependencies
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600201 goto:error
Jeff Juliano6c1422c2017-08-26 10:04:29 -0400202 )
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600203
204REM // ======== end Parameter parsing ======== //
205
206
207REM // ======== Dependency checking ======== //
208 REM git is required for all paths
209 for %%X in (git.exe) do (set FOUND=%%~$PATH:X)
210 if not defined FOUND (
211 echo Dependency check failed:
212 echo git.exe not found
213 echo Git for Windows can be downloaded here: https://git-scm.com/download/win
214 echo Install and ensure git.exe makes it into your PATH
215 set errorCode=1
216 )
217
218 if %check-glslang-build-dependencies% equ 1 (
219 for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)
220 if not defined FOUND (
221 echo Dependency check failed:
222 echo cmake.exe not found
Jeff Julianoede64a72017-08-26 08:20:51 -0400223 echo Get CMake for Windows here: http://www.cmake.org/cmake/resources/software.html
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600224 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"
225 set errorCode=1
226 )
227 )
228
229
230 REM goto:main
231
232REM // ======== end Dependency checking ======== //
233
234:main
235
236if %errorCode% neq 0 (goto:error)
237
238REM Read the target versions from external file, which is shared with Linux script
239
Mike Weiblen22489252017-02-16 17:00:35 -0700240if not exist %REVISION_DIR%\glslang_giturl (
241 echo.
242 echo Missing glslang_giturl file! Place it in %REVISION_DIR% with git repo URL in it.
243 set errorCode=1
244 goto:error
245)
246
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700247if not exist %REVISION_DIR%\glslang_revision (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600248 echo.
Mike Weiblen22489252017-02-16 17:00:35 -0700249 echo Missing glslang_revision file! Place it in %REVISION_DIR% with target version in it.
250 set errorCode=1
251 goto:error
252)
253
Mike Weiblen22489252017-02-16 17:00:35 -0700254set /p GLSLANG_GITURL= < %REVISION_DIR%\glslang_giturl
Mark Lobodzinski1e4da612016-11-18 13:20:36 -0700255set /p GLSLANG_REVISION= < %REVISION_DIR%\glslang_revision
Mike Weiblen22489252017-02-16 17:00:35 -0700256
257echo GLSLANG_GITURL=%GLSLANG_GITURL%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600258echo GLSLANG_REVISION=%GLSLANG_REVISION%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600259
260
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700261echo Creating and/or updating glslang in %BASE_DIR%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600262
263if %sync-glslang% equ 1 (
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600264 if not exist %GLSLANG_DIR% (
265 call:create_glslang
266 )
267 if %errorCode% neq 0 (goto:error)
268 call:update_glslang
269 if %errorCode% neq 0 (goto:error)
270)
271
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600272if %build-glslang% equ 1 (
273 call:build_glslang
274 if %errorCode% neq 0 (goto:error)
275)
276
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600277echo.
278echo Exiting
279goto:finish
280
281:error
282echo.
283echo Halting due to error
Tony Barbour62f40db2017-06-21 10:22:05 -0600284set errorCode=1
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600285goto:finish
286
287:finish
288if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
Tony Barbour62f40db2017-06-21 10:22:05 -0600289exit /b %errorCode%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600290
291
292REM // ======== Functions ======== //
293
294:create_glslang
295 echo.
296 echo Creating local glslang repository %GLSLANG_DIR%)
297 mkdir %GLSLANG_DIR%
298 cd %GLSLANG_DIR%
Mike Weiblen22489252017-02-16 17:00:35 -0700299 git clone %GLSLANG_GITURL% .
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600300 git checkout %GLSLANG_REVISION%
saschawillems4eebd7f2017-11-03 15:27:27 +0100301 python.exe .\update_glslang_sources.py
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600302 if not exist %GLSLANG_DIR%\SPIRV (
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700303 echo glslang source download failed!
304 set errorCode=1
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600305 )
306goto:eof
307
308:update_glslang
309 echo.
310 echo Updating %GLSLANG_DIR%
311 cd %GLSLANG_DIR%
312 git fetch --all
313 git checkout %GLSLANG_REVISION%
saschawillems4eebd7f2017-11-03 15:27:27 +0100314 python.exe .\update_glslang_sources.py
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600315goto:eof
316
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600317:build_glslang
318 echo.
319 echo Building %GLSLANG_DIR%
320 cd %GLSLANG_DIR%
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700321
Lenny Komow3b62ce82016-11-29 14:24:39 -0700322 if not exist build32 (
323 mkdir build32
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600324 )
Lenny Komow3b62ce82016-11-29 14:24:39 -0700325 if not exist build (
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700326 mkdir build
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600327 )
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700328
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600329 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32
Karl Schultz0e417132018-01-03 12:50:46 -0700330 if %do_32% equ 1 (
331 echo Making 32-bit glslang
332 echo *************************
333 cd %GLSLANG_BUILD_DIR%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600334
Karl Schultz0e417132018-01-03 12:50:46 -0700335 echo Generating 32-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
336 cmake -G "Visual Studio %VS_VERSION%" -DCMAKE_INSTALL_PREFIX=install ..
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700337
Karl Schultz0e417132018-01-03 12:50:46 -0700338 if %do_debug% equ 1 (
339 echo Building 32-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug
340 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700341
Karl Schultz0e417132018-01-03 12:50:46 -0700342 REM Check for existence of one lib, even though we should check for all results
343 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
344 echo.
345 echo glslang 32-bit Debug build failed!
346 set errorCode=1
347 )
348 )
349 if %do_release% equ 1 (
350 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release
351 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700352
Karl Schultz0e417132018-01-03 12:50:46 -0700353 REM Check for existence of one lib, even though we should check for all results
354 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
355 echo.
356 echo glslang 32-bit Release build failed!
357 set errorCode=1
358 )
359 )
360 cd ..
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600361 )
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700362
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600363 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
Karl Schultz0e417132018-01-03 12:50:46 -0700364 if %do_64% equ 1 (
365 echo Making 64-bit glslang
366 echo *************************
367 cd %GLSLANG_BUILD_DIR%
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600368
Karl Schultz0e417132018-01-03 12:50:46 -0700369 echo Generating 64-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
370 cmake -G "Visual Studio %VS_VERSION% Win64" -DCMAKE_INSTALL_PREFIX=install ..
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700371
Karl Schultz0e417132018-01-03 12:50:46 -0700372 if %do_debug% equ 1 (
373 echo Building 64-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
374 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700375
Karl Schultz0e417132018-01-03 12:50:46 -0700376 REM Check for existence of one lib, even though we should check for all results
377 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
378 echo.
379 echo glslang 64-bit Debug build failed!
380 set errorCode=1
381 )
382 )
383 if %do_release% equ 1 (
384 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
385 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
386
387 REM Check for existence of one lib, even though we should check for all results
388 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
389 echo.
390 echo glslang 64-bit Release build failed!
391 set errorCode=1
392 )
393 )
394 cd ..
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600395 )
Mark Lobodzinski4f5ce472017-11-16 13:23:05 -0700396
Mark Lobodzinski0e393752016-05-04 09:19:54 -0600397goto:eof