blob: be2d8d417a8bb9008a9ec25be1640adc52dbed5b [file] [log] [blame]
Cody Northrop5934a882015-05-12 16:23:59 -06001@echo off
Karl Schultz5d288592016-02-22 09:57:14 -07002REM Update source for glslang, spirv-tools
Cody Northrop5934a882015-05-12 16:23:59 -06003
Mark Youngd6f8faa2016-01-07 12:41:14 -07004REM 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
Mark Youngd6f8faa2016-01-07 12:41:14 -070010REM Cleanup the file we used to collect the VS version output since it's no longer needed.
11del /Q /F vsversion.tmp
12
Cody Northrop5934a882015-05-12 16:23:59 -060013setlocal EnableDelayedExpansion
14set errorCode=0
15set BUILD_DIR=%~dp0
16set BASE_DIR=%BUILD_DIR%..
17set GLSLANG_DIR=%BASE_DIR%\glslang
Cody Northrope58683f2015-12-30 11:53:18 -070018set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools
Cody Northrop5934a882015-05-12 16:23:59 -060019
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
Mark Youngd6f8faa2016-01-07 12:41:14 -070027 echo --sync-spirv-tools just pull spirv-tools_revision
Cody Northrop5934a882015-05-12 16:23:59 -060028 echo --build-glslang pulls glslang_revision, configures CMake, builds Release and Debug
Cody Northrope58683f2015-12-30 11:53:18 -070029 echo --build-spirv-tools pulls spirv-tools_revision, configures CMake, builds Release and Debug
30 echo --all sync and build glslang, LunarGLASS, spirv-tools
Cody Northrop5934a882015-05-12 16:23:59 -060031 goto:finish
32 )
33
34 set sync-glslang=0
Cody Northrope58683f2015-12-30 11:53:18 -070035 set sync-spirv-tools=0
Cody Northrop5934a882015-05-12 16:23:59 -060036 set build-glslang=0
Cody Northrope58683f2015-12-30 11:53:18 -070037 set build-spirv-tools=0
Cody Northrop5934a882015-05-12 16:23:59 -060038 set check-glslang-build-dependencies=0
Cody Northrop5934a882015-05-12 16:23:59 -060039
40 :parameterLoop
41
42 if "%1"=="" goto:parameterContinue
43
44 if "%1" == "--sync-glslang" (
45 set sync-glslang=1
Cody Northrop4f30cdf2015-10-13 10:30:27 -060046 shift
47 goto:parameterLoop
Cody Northrop5934a882015-05-12 16:23:59 -060048 )
49
Cody Northrope58683f2015-12-30 11:53:18 -070050 if "%1" == "--sync-spirv-tools" (
51 set sync-spirv-tools=1
52 shift
53 goto:parameterLoop
54 )
55
Cody Northrop5934a882015-05-12 16:23:59 -060056 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
Cody Northrope58683f2015-12-30 11:53:18 -070064 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
Cody Northrop5934a882015-05-12 16:23:59 -060073 if "%1" == "--all" (
74 set sync-glslang=1
Cody Northrope58683f2015-12-30 11:53:18 -070075 set sync-spirv-tools=1
Cody Northrop5934a882015-05-12 16:23:59 -060076 set build-glslang=1
Cody Northrope58683f2015-12-30 11:53:18 -070077 set build-spirv-tools=1
Cody Northrop5934a882015-05-12 16:23:59 -060078 set check-glslang-build-dependencies=1
Cody Northrop5934a882015-05-12 16:23:59 -060079 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 ======== //
Cody Northrop4f30cdf2015-10-13 10:30:27 -060092 REM git is required for all paths
Cody Northropf91add82015-07-02 11:33:41 -060093 for %%X in (git.exe) do (set FOUND=%%~$PATH:X)
Cody Northrop5934a882015-05-12 16:23:59 -060094 if not defined FOUND (
95 echo Dependency check failed:
Cody Northropf91add82015-07-02 11:33:41 -060096 echo git.exe not found
Cody Northrop4f30cdf2015-10-13 10:30:27 -060097 echo Git for Windows can be downloaded here: https://git-scm.com/download/win
Cody Northropf91add82015-07-02 11:33:41 -060098 echo Install and ensure git.exe makes it into your PATH
Cody Northrop5934a882015-05-12 16:23:59 -060099 set errorCode=1
100 )
101
Cody Northrop5934a882015-05-12 16:23:59 -0600102 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
Cody Northrop5934a882015-05-12 16:23:59 -0600113
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
Cody Northrop5934a882015-05-12 16:23:59 -0600123
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
Cody Northrope58683f2015-12-30 11:53:18 -0700131if 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
Cody Northrop5934a882015-05-12 16:23:59 -0600138set /p GLSLANG_REVISION= < glslang_revision
Cody Northrope58683f2015-12-30 11:53:18 -0700139set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision
Cody Northrop5934a882015-05-12 16:23:59 -0600140echo GLSLANG_REVISION=%GLSLANG_REVISION%
Cody Northrope58683f2015-12-30 11:53:18 -0700141echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
Cody Northrop5934a882015-05-12 16:23:59 -0600142
GregF22880882015-09-23 11:16:44 -0600143
Karl Schultz5d288592016-02-22 09:57:14 -0700144echo Creating and/or updating glslang, spirv-tools in %BASE_DIR%
Cody Northrop5934a882015-05-12 16:23:59 -0600145
146if %sync-glslang% equ 1 (
Peter Lohrmann18c06a22016-02-16 15:20:58 -0800147 if exist %GLSLANG_DIR% (
148 rd /S /Q %GLSLANG_DIR%
149 )
Cody Northrop5934a882015-05-12 16:23:59 -0600150 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
Cody Northrope58683f2015-12-30 11:53:18 -0700158if %sync-spirv-tools% equ 1 (
Peter Lohrmann18c06a22016-02-16 15:20:58 -0800159 if exist %SPIRV_TOOLS_DIR% (
160 rd /S /Q %SPIRV_TOOLS_DIR%
161 )
Cody Northrope58683f2015-12-30 11:53:18 -0700162 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
Cody Northrop5934a882015-05-12 16:23:59 -0600171if %build-glslang% equ 1 (
172 call:build_glslang
173 if %errorCode% neq 0 (goto:error)
174)
175
Cody Northrope58683f2015-12-30 11:53:18 -0700176if %build-spirv-tools% equ 1 (
177 call:build_spirv-tools
178 if %errorCode% neq 0 (goto:error)
179)
180
Cody Northrop5934a882015-05-12 16:23:59 -0600181echo.
Cody Northrope58683f2015-12-30 11:53:18 -0700182echo Exiting
Cody Northrop5934a882015-05-12 16:23:59 -0600183goto: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
Cody Northrop5934a882015-05-12 16:23:59 -0600200 echo.
201 echo Creating local glslang repository %GLSLANG_DIR%)
202 mkdir %GLSLANG_DIR%
203 cd %GLSLANG_DIR%
Peter Lohrmann18c06a22016-02-16 15:20:58 -0800204 git clone https://github.com/KhronosGroup/glslang.git .
Cody Northropf91add82015-07-02 11:33:41 -0600205 git checkout %GLSLANG_REVISION%
Cody Northrop5934a882015-05-12 16:23:59 -0600206 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%
Greg Fischer09792302015-10-08 17:53:48 -0600216 git fetch --all
Greg Fischer5467e752015-10-02 13:05:27 -0600217 git checkout %GLSLANG_REVISION%
Cody Northrop5934a882015-05-12 16:23:59 -0600218goto:eof
219
Cody Northrope58683f2015-12-30 11:53:18 -0700220:create_spirv-tools
221 echo.
222 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%)
223 mkdir %SPIRV_TOOLS_DIR%
224 cd %SPIRV_TOOLS_DIR%
Peter Lohrmann18c06a22016-02-16 15:20:58 -0800225 git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
Cody Northrope58683f2015-12-30 11:53:18 -0700226 git checkout %SPIRV_TOOLS_REVISION%
227 if not exist %SPIRV_TOOLS_DIR%\source (
228 echo spirv-tools source download failed!
229 set errorCode=1
230 )
231goto:eof
232
233:update_spirv-tools
234 echo.
235 echo Updating %SPIRV_TOOLS_DIR%
236 cd %SPIRV_TOOLS_DIR%
237 git fetch --all
238 git checkout %SPIRV_TOOLS_REVISION%
239goto:eof
240
Cody Northrop5934a882015-05-12 16:23:59 -0600241:build_glslang
242 echo.
243 echo Building %GLSLANG_DIR%
244 cd %GLSLANG_DIR%
Mark Young93ecb1d2016-01-13 13:47:16 -0700245
246 REM Cleanup any old directories lying around.
Peter Lohrmann18c06a22016-02-16 15:20:58 -0800247 if exist build32 (
248 rmdir /s /q build32
249 )
250 if exist build (
251 rmdir /s /q build
252 )
Mark Young93ecb1d2016-01-13 13:47:16 -0700253
254 echo Making 32-bit glslang
255 echo *************************
256 mkdir build32
257 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32
Cody Northrop5934a882015-05-12 16:23:59 -0600258 cd %GLSLANG_BUILD_DIR%
Mark Young93ecb1d2016-01-13 13:47:16 -0700259
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 ..
262
263 echo Building 32-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug
Mark Young4ae88c52016-02-01 11:43:39 -0700264 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
Mark Young93ecb1d2016-01-13 13:47:16 -0700265
Cody Northrop5934a882015-05-12 16:23:59 -0600266 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 (
268 echo.
Mark Young93ecb1d2016-01-13 13:47:16 -0700269 echo glslang 32-bit Debug build failed!
Cody Northrop5934a882015-05-12 16:23:59 -0600270 set errorCode=1
271 )
Mark Young93ecb1d2016-01-13 13:47:16 -0700272 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release
Mark Young4ae88c52016-02-01 11:43:39 -0700273 msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
Mark Young93ecb1d2016-01-13 13:47:16 -0700274
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600275 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 (
277 echo.
Mark Young93ecb1d2016-01-13 13:47:16 -0700278 echo glslang 32-bit Release build failed!
279 set errorCode=1
280 )
281
282 cd ..
283
284 echo Making 64-bit glslang
285 echo *************************
Mark Youngecf45822016-01-18 15:48:20 -0700286 mkdir build
287 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
Mark Young93ecb1d2016-01-13 13:47:16 -0700288 cd %GLSLANG_BUILD_DIR%
289
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 ..
292
293 echo Building 64-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
Mark Young4ae88c52016-02-01 11:43:39 -0700294 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
Mark Young93ecb1d2016-01-13 13:47:16 -0700295
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 (
298 echo.
299 echo glslang 64-bit Debug build failed!
300 set errorCode=1
301 )
302 echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
Mark Young4ae88c52016-02-01 11:43:39 -0700303 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
Mark Young93ecb1d2016-01-13 13:47:16 -0700304
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 (
307 echo.
308 echo glslang 64-bit Release build failed!
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600309 set errorCode=1
310 )
Cody Northrop5934a882015-05-12 16:23:59 -0600311goto:eof
312
Cody Northrope58683f2015-12-30 11:53:18 -0700313:build_spirv-tools
314 echo.
315 echo Building %SPIRV_TOOLS_DIR%
316 cd %SPIRV_TOOLS_DIR%
Mark Young93ecb1d2016-01-13 13:47:16 -0700317
318 REM Cleanup any old directories lying around.
Peter Lohrmann18c06a22016-02-16 15:20:58 -0800319 if exist build32 (
320 rmdir /s /q build32
321 )
322 if exist build (
323 rmdir /s /q build
324 )
Mark Younga81e6082016-01-15 12:35:39 -0700325
Mark Young93ecb1d2016-01-13 13:47:16 -0700326 echo Making 32-bit spirv-tools
327 echo *************************
328 mkdir build32
329 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build32
Mark Young1ef23302016-01-13 13:47:16 -0700330
Cody Northrope58683f2015-12-30 11:53:18 -0700331 cd %SPIRV_TOOLS_BUILD_DIR%
Mark Young93ecb1d2016-01-13 13:47:16 -0700332
333 echo Generating 32-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
Mark Youngd6f8faa2016-01-07 12:41:14 -0700334 cmake -G "Visual Studio %VS_VERSION%" ..
Mark Young93ecb1d2016-01-13 13:47:16 -0700335
336 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug
Mark Young4ae88c52016-02-01 11:43:39 -0700337 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet
Mark Young93ecb1d2016-01-13 13:47:16 -0700338
Cody Northrope58683f2015-12-30 11:53:18 -0700339 REM Check for existence of one lib, even though we should check for all results
GregFc283d0e2016-04-01 14:20:14 -0600340 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
Cody Northrope58683f2015-12-30 11:53:18 -0700341 echo.
Mark Young93ecb1d2016-01-13 13:47:16 -0700342 echo spirv-tools 32-bit Debug build failed!
Cody Northrope58683f2015-12-30 11:53:18 -0700343 set errorCode=1
344 )
Mark Young93ecb1d2016-01-13 13:47:16 -0700345
346 echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release
Mark Young4ae88c52016-02-01 11:43:39 -0700347 msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet
Mark Young93ecb1d2016-01-13 13:47:16 -0700348
Cody Northrope58683f2015-12-30 11:53:18 -0700349 REM Check for existence of one lib, even though we should check for all results
GregFc283d0e2016-04-01 14:20:14 -0600350 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
Cody Northrope58683f2015-12-30 11:53:18 -0700351 echo.
Mark Young93ecb1d2016-01-13 13:47:16 -0700352 echo spirv-tools 32-bit Release build failed!
353 set errorCode=1
354 )
355
356 cd ..
357
358 echo Making 64-bit spirv-tools
359 echo *************************
Mark Youngecf45822016-01-18 15:48:20 -0700360 mkdir build
361 set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build
Mark Young93ecb1d2016-01-13 13:47:16 -0700362 cd %SPIRV_TOOLS_BUILD_DIR%
Mark Youngc2f10212016-01-13 13:47:16 -0700363
Mark Young93ecb1d2016-01-13 13:47:16 -0700364 echo Generating 64-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
365 cmake -G "Visual Studio %VS_VERSION% Win64" ..
366
367 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug
Mark Young4ae88c52016-02-01 11:43:39 -0700368 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet
Mark Young93ecb1d2016-01-13 13:47:16 -0700369
370 REM Check for existence of one lib, even though we should check for all results
GregFc283d0e2016-04-01 14:20:14 -0600371 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
Mark Young93ecb1d2016-01-13 13:47:16 -0700372 echo.
373 echo spirv-tools 64-bit Debug build failed!
374 set errorCode=1
375 )
376
377 echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release
Mark Young4ae88c52016-02-01 11:43:39 -0700378 msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet
Mark Young93ecb1d2016-01-13 13:47:16 -0700379
380 REM Check for existence of one lib, even though we should check for all results
GregFc283d0e2016-04-01 14:20:14 -0600381 if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
Mark Young93ecb1d2016-01-13 13:47:16 -0700382 echo.
383 echo spirv-tools 64-bit Release build failed!
Cody Northrope58683f2015-12-30 11:53:18 -0700384 set errorCode=1
385 )
386goto:eof