blob: 0a391fc96594568e1b50737f07fd21046dbf1432 [file] [log] [blame]
Cody Northrop5934a882015-05-12 16:23:59 -06001@echo off
2REM Update source for glslang (and eventually LunarGLASS)
3
4setlocal EnableDelayedExpansion
5set errorCode=0
6set BUILD_DIR=%~dp0
7set BASE_DIR=%BUILD_DIR%..
8set GLSLANG_DIR=%BASE_DIR%\glslang
9set LUNARGLASS_DIR=%BASE_DIR%\LunarGLASS
10
11REM // ======== Parameter parsing ======== //
12
13 if "%1" == "" (
14 echo usage: update_external_sources.bat [options]
15 echo.
16 echo Available options:
17 echo --sync-glslang just pull glslang_revision
18 echo --sync-LunarGLASS just pull LunarGLASS_revision
19 echo --build-glslang pulls glslang_revision, configures CMake, builds Release and Debug
20 echo --build-LunarGLASS pulls LunarGLASS_revision, configures CMake, builds Release and Debug
21 echo --all sync and build both glslang and LunarGLASS
22 goto:finish
23 )
24
25 set sync-glslang=0
26 set sync-LunarGLASS=0
27 set build-glslang=0
28 set build-LunarGLASS=0
Cody Northrop5934a882015-05-12 16:23:59 -060029 set check-glslang-build-dependencies=0
Cody Northropf91add82015-07-02 11:33:41 -060030 set check-LunarGLASS-fetch-dependencies=0
Cody Northrop5934a882015-05-12 16:23:59 -060031 set check-LunarGLASS-build-dependencies=0
32
33 :parameterLoop
34
35 if "%1"=="" goto:parameterContinue
36
37 if "%1" == "--sync-glslang" (
38 set sync-glslang=1
Cody Northrop4f30cdf2015-10-13 10:30:27 -060039 shift
40 goto:parameterLoop
Cody Northrop5934a882015-05-12 16:23:59 -060041 )
42
43 if "%1" == "--sync-LunarGLASS" (
44 set sync-LunarGLASS=1
Cody Northropf91add82015-07-02 11:33:41 -060045 set check-LunarGLASS-fetch-dependencies=1
Cody Northrop5934a882015-05-12 16:23:59 -060046 shift
47 goto:parameterLoop
48 )
49
50 if "%1" == "--build-glslang" (
51 set sync-glslang=1
52 set check-glslang-build-dependencies=1
53 set build-glslang=1
54 shift
55 goto:parameterLoop
56 )
57
58 if "%1" == "--build-LunarGLASS" (
59 set sync-LunarGLASS=1
Cody Northropf91add82015-07-02 11:33:41 -060060 set check-LunarGLASS-fetch-dependencies=1
Cody Northrop5934a882015-05-12 16:23:59 -060061 set check-LunarGLASS-build-dependencies=1
62 set build-LunarGLASS=1
63 shift
64 goto:parameterLoop
65 )
66
67 if "%1" == "--all" (
68 set sync-glslang=1
69 set sync-LunarGLASS=1
70 set build-glslang=1
71 set build-LunarGLASS=1
Cody Northropf91add82015-07-02 11:33:41 -060072 set check-LunarGLASS-fetch-dependencies=1
Cody Northrop5934a882015-05-12 16:23:59 -060073 set check-glslang-build-dependencies=1
74 set check-LunarGLASS-build-dependencies=1
75 shift
76 goto:parameterLoop
77 )
78
79 echo Unrecognized options "%1"
80 goto:error
81
82 :parameterContinue
83
84REM // ======== end Parameter parsing ======== //
85
86
87REM // ======== Dependency checking ======== //
Cody Northrop4f30cdf2015-10-13 10:30:27 -060088 REM git is required for all paths
Cody Northropf91add82015-07-02 11:33:41 -060089 for %%X in (git.exe) do (set FOUND=%%~$PATH:X)
Cody Northrop5934a882015-05-12 16:23:59 -060090 if not defined FOUND (
91 echo Dependency check failed:
Cody Northropf91add82015-07-02 11:33:41 -060092 echo git.exe not found
Cody Northrop4f30cdf2015-10-13 10:30:27 -060093 echo Git for Windows can be downloaded here: https://git-scm.com/download/win
Cody Northropf91add82015-07-02 11:33:41 -060094 echo Install and ensure git.exe makes it into your PATH
Cody Northrop5934a882015-05-12 16:23:59 -060095 set errorCode=1
96 )
97
Cody Northropf91add82015-07-02 11:33:41 -060098 if %check-LunarGLASS-fetch-dependencies% equ 1 (
99 for %%X in (svn.exe) do (set FOUND=%%~$PATH:X)
100 if not defined FOUND (
101 echo Dependency check failed:
102 echo svn.exe not found
103 echo Get Subversion for Windows here: http://sourceforge.net/projects/win32svn/
104 echo Install and ensure svn.exe makes it into your PATH, default is "C:\Program Files (x86)\Subversion\bin"
105 set errorCode=1
106 )
107
Cody Northrop5934a882015-05-12 16:23:59 -0600108 for %%X in (wget.exe) do (set FOUND=%%~$PATH:X)
109 if not defined FOUND (
110 echo Dependency check failed:
111 echo wget.exe not found
112 echo Get wget for Windows here: http://gnuwin32.sourceforge.net/packages/wget.htm
113 echo Easiest to select "Complete package, except sources" link which will install and setup PATH
114 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\GnuWin32\bin"
115 set errorCode=1
116 )
117
118 for %%X in (gzip.exe) do (set FOUND=%%~$PATH:X)
119 if not defined FOUND (
120 echo Dependency check failed:
121 echo gzip.exe not found
122 echo Get gzip for Windows here: http://gnuwin32.sourceforge.net/packages/gzip.htm
123 echo Easiest to select "Complete package, except sources" link which will install and setup PATH
124 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\GnuWin32\bin"
125 set errorCode=1
126 )
127
128 for %%X in (tar.exe) do (set FOUND=%%~$PATH:X)
129 if not defined FOUND (
130 echo Dependency check failed:
131 echo tar.exe not found
132 echo Get tar for Windows here: http://gnuwin32.sourceforge.net/packages/gtar.htm
133 echo Easiest to select Binaries/Setup link which will install and setup PATH
134 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\GnuWin32\bin"
135 set errorCode=1
136 )
137 )
138
139 if %check-glslang-build-dependencies% equ 1 (
140 for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)
141 if not defined FOUND (
142 echo Dependency check failed:
143 echo cmake.exe not found
144 echo Get CNake 2.8 for Windows here: http://www.cmake.org/cmake/resources/software.html
145 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"
146 set errorCode=1
147 )
148 )
149
150 if %check-LunarGLASS-build-dependencies% equ 1 (
151 for %%X in (python.exe) do (set FOUND=%%~$PATH:X)
152 if not defined FOUND (
153 echo Dependency check failed:
154 echo python.exe not found
155 echo Get python 2.7x for Windows here: http://www.python.org/download/releases/2.7.6/
156 echo Install and ensure each makes it into your PATH, default is "C:\Python27"
157 set errorCode=1
158 )
159
160 for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)
161 if not defined FOUND (
162 echo Dependency check failed:
163 echo cmake.exe not found
164 echo Get CNake 2.8 for Windows here: http://www.cmake.org/cmake/resources/software.html
165 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"
166 set errorCode=1
167 )
168 )
169
170 REM goto:main
171
172REM // ======== end Dependency checking ======== //
173
174:main
175
176if %errorCode% neq 0 (goto:error)
177
178REM Read the target versions from external file, which is shared with Linux script
179if not exist LunarGLASS_revision (
180 echo.
181 echo Missing LunarGLASS_revision file! Place it next to this script with target version in it.
182 set errorCode=1
183 goto:error
184)
185
186if not exist glslang_revision (
187 echo.
188 echo Missing glslang_revision file! Place it next to this script with target version in it.
189 set errorCode=1
190 goto:error
191)
192
193set /p LUNARGLASS_REVISION= < LunarGLASS_revision
194set /p GLSLANG_REVISION= < glslang_revision
195echo LUNARGLASS_REVISION=%LUNARGLASS_REVISION%
196echo GLSLANG_REVISION=%GLSLANG_REVISION%
197
GregF22880882015-09-23 11:16:44 -0600198set /p LUNARGLASS_REVISION_R32= < LunarGLASS_revision_R32
GregF22880882015-09-23 11:16:44 -0600199echo LUNARGLASS_REVISION_R32=%LUNARGLASS_REVISION_R32%
GregF22880882015-09-23 11:16:44 -0600200
Cody Northrop5934a882015-05-12 16:23:59 -0600201echo Creating and/or updating glslang and LunarGLASS in %BASE_DIR%
202
203if %sync-glslang% equ 1 (
GregF22880882015-09-23 11:16:44 -0600204 rd /S /Q %GLSLANG_DIR%
Cody Northrop5934a882015-05-12 16:23:59 -0600205 if not exist %GLSLANG_DIR% (
206 call:create_glslang
207 )
208 if %errorCode% neq 0 (goto:error)
209 call:update_glslang
210 if %errorCode% neq 0 (goto:error)
211)
212
213if %sync-LunarGLASS% equ 1 (
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600214 rd /S /Q %LUNARGLASS_DIR%
Cody Northrop5934a882015-05-12 16:23:59 -0600215 if not exist %LUNARGLASS_DIR% (
216 call:create_LunarGLASS
217 )
218 if %errorCode% neq 0 (goto:error)
219 call:update_LunarGLASS
220 if %errorCode% neq 0 (goto:error)
221)
222
223if %build-glslang% equ 1 (
224 call:build_glslang
225 if %errorCode% neq 0 (goto:error)
226)
227
228if %build-LunarGLASS% equ 1 (
229 call:build_LunarGLASS
230 if %errorCode% neq 0 (goto:error)
231)
232
233REM If we made it here, we are golden
234echo.
235echo Success
236goto:finish
237
238:error
239echo.
240echo Halting due to error
241goto:finish
242
243:finish
244if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
245endlocal
246goto:eof
247
248
249
250REM // ======== Functions ======== //
251
252:create_glslang
Cody Northrop5934a882015-05-12 16:23:59 -0600253 echo.
254 echo Creating local glslang repository %GLSLANG_DIR%)
255 mkdir %GLSLANG_DIR%
256 cd %GLSLANG_DIR%
Greg Fischer5467e752015-10-02 13:05:27 -0600257 git clone git@gitlab.khronos.org:GLSL/glslang.git .
Cody Northropf91add82015-07-02 11:33:41 -0600258 git checkout %GLSLANG_REVISION%
Cody Northrop5934a882015-05-12 16:23:59 -0600259 if not exist %GLSLANG_DIR%\SPIRV (
260 echo glslang source download failed!
261 set errorCode=1
262 )
263goto:eof
264
265:update_glslang
266 echo.
267 echo Updating %GLSLANG_DIR%
268 cd %GLSLANG_DIR%
Greg Fischer09792302015-10-08 17:53:48 -0600269 git fetch --all
Greg Fischer5467e752015-10-02 13:05:27 -0600270 git checkout %GLSLANG_REVISION%
Cody Northrop5934a882015-05-12 16:23:59 -0600271goto:eof
272
273:create_LunarGLASS
274 REM Windows complains if it can't find the directory below, no need to call
275 REM rd /S /Q %LUNARGLASS_DIR%
276 echo.
277 echo Creating local LunarGLASS repository %LUNARGLASS_DIR%)
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600278 mkdir %LUNARGLASS_DIR%
279 cd %LUNARGLASS_DIR%
280 git clone https://github.com/LunarG/LunarGLASS.git .
281 git checkout %LUNARGLASS_REVISION%
282 cd Core\LLVM
Cody Northrop5934a882015-05-12 16:23:59 -0600283 echo.
284 echo Downloading LLVM archive...
285 wget http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz
286 REM tar on windows can't filter through gzip, so the below line doesn't work
287 REM tar --gzip -xf llvm-3.4.src.tar.gz
288 echo.
289 echo Unzipping the archive...
290 echo gzip --decompress --verbose --keep llvm-3.4.src.tar.gz
291 gzip --decompress --verbose --keep llvm-3.4.src.tar.gz
292 echo.
293 echo Extracting the archive... (this is slow)
294 echo tar -xf llvm-3.4.src.tar
295 tar -xf llvm-3.4.src.tar
296 if not exist %LUNARGLASS_DIR%\Core\LLVM\llvm-3.4\lib (
297 echo .
298 echo LLVM source download failed!
299 echo Delete LunarGLASS directory and try again
300 set errorCode=1
301 goto:eof
302 )
303 echo.
304 echo Syncing LunarGLASS source...
305 cd %LUNARGLASS_DIR%
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600306 REM put back the LunarGLASS github versions of some LLVM files
307 git checkout -f .
308 REM overwrite with private gitlab versions of some files
309 svn checkout -r %LUNARGLASS_REVISION_R32% --force https://cvs.khronos.org/svn/repos/SPIRV/trunk/LunarGLASS/ .
310 svn revert -R .
Cody Northrop5934a882015-05-12 16:23:59 -0600311 if not exist %LUNARGLASS_DIR%\Frontends\SPIRV (
312 echo.
313 echo LunarGLASS source download failed!
314 set errorCode=1
315 )
316goto:eof
317
318:update_LunarGLASS
319 echo.
320 echo Updating %LUNARGLASS_DIR%
321 cd %LUNARGLASS_DIR%
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600322 git fetch --all
323 git checkout -f %LUNARGLASS_REVISION% .
324 if not exist %LUNARGLASS_DIR%\.svn (
325 svn checkout -r %LUNARGLASS_REVISION_R32% --force https://cvs.khronos.org/svn/repos/SPIRV/trunk/LunarGLASS/ .
326 )
327 svn update -r %LUNARGLASS_REVISION_R325
Cody Northrop5934a882015-05-12 16:23:59 -0600328 svn revert -R .
329goto:eof
330
331:build_glslang
332 echo.
333 echo Building %GLSLANG_DIR%
334 cd %GLSLANG_DIR%
335 mkdir build
336 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
337 cd %GLSLANG_BUILD_DIR%
338 cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
Cody Northrop5934a882015-05-12 16:23:59 -0600339 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
340 REM Check for existence of one lib, even though we should check for all results
341 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslang.lib (
342 echo.
343 echo glslang Debug build failed!
344 set errorCode=1
345 )
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600346 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
347 REM Check for existence of one lib, even though we should check for all results
348 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
349 echo.
350 echo glslang Release build failed!
351 set errorCode=1
352 )
Cody Northrop5934a882015-05-12 16:23:59 -0600353goto:eof
354
355:build_LunarGLASS
356 echo.
357 echo Building %LUNARGLASS_DIR%
358 set LLVM_DIR=%LUNARGLASS_DIR%\Core\LLVM\llvm-3.4
359 cd %LLVM_DIR%
360 mkdir build
361 set LLVM_BUILD_DIR=%LLVM_DIR%\build
362 cd %LLVM_BUILD_DIR%
363 cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
364 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
365 REM Check for existence of one lib, even though we should check for all results
366 if not exist %LLVM_BUILD_DIR%\lib\Release\LLVMCore.lib (
367 echo.
368 echo LLVM Release build failed!
369 set errorCode=1
370 goto:eof
371 )
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600372 REM disable Debug build of LLVM until LunarGLASS cmake files are updated to
373 REM handle Debug and Release builds of glslang simultaneously, instead of
374 REM whatever last lands in "./build/install"
375 REM msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
Cody Northrop5934a882015-05-12 16:23:59 -0600376 REM Check for existence of one lib, even though we should check for all results
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600377 REM if not exist %LLVM_BUILD_DIR%\lib\Debug\LLVMCore.lib (
378 REM echo.
379 REM echo LLVM Debug build failed!
380 REM set errorCode=1
381 REM goto:eof
382 REM )
Cody Northrop5934a882015-05-12 16:23:59 -0600383 cd %LUNARGLASS_DIR%
384 mkdir build
385 set LUNARGLASS_BUILD_DIR=%LUNARGLASS_DIR%\build
386 cd %LUNARGLASS_BUILD_DIR%
387 cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
388 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
389 REM Check for existence of one lib, even though we should check for all results
390 if not exist %LUNARGLASS_BUILD_DIR%\Core\Release\core.lib (
391 echo.
392 echo LunarGLASS build failed!
393 set errorCode=1
394 goto:eof
395 )
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600396 REM disable Debug build of LunarGLASS until its cmake file can be updated to
397 REM handle Debug and Release builds of glslang simultaneously, instead of
398 REM whatever last lands in "./build/install"
399 REM msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
Cody Northrop5934a882015-05-12 16:23:59 -0600400 REM Check for existence of one lib, even though we should check for all results
Cody Northrop4f30cdf2015-10-13 10:30:27 -0600401 REM if not exist %LUNARGLASS_BUILD_DIR%\Core\Debug\core.lib (
402 REM echo.
403 REM echo LunarGLASS build failed!
404 REM set errorCode=1
405 REM goto:eof
406 REM )
Cody Northrop5934a882015-05-12 16:23:59 -0600407goto:eof