blob: e4bb45460abc85e4c07a0f4fff1bb41652ea64e2 [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
39 shift
40 goto:parameterLoop
41 )
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 Northropf91add82015-07-02 11:33:41 -060088 for %%X in (git.exe) do (set FOUND=%%~$PATH:X)
Cody Northrop5934a882015-05-12 16:23:59 -060089 if not defined FOUND (
90 echo Dependency check failed:
Cody Northropf91add82015-07-02 11:33:41 -060091 echo git.exe not found
92 echo Install and ensure git.exe makes it into your PATH
93
Cody Northrop5934a882015-05-12 16:23:59 -060094 set errorCode=1
95 )
96
Cody Northropf91add82015-07-02 11:33:41 -060097 if %check-LunarGLASS-fetch-dependencies% equ 1 (
98 for %%X in (svn.exe) do (set FOUND=%%~$PATH:X)
99 if not defined FOUND (
100 echo Dependency check failed:
101 echo svn.exe not found
102 echo Get Subversion for Windows here: http://sourceforge.net/projects/win32svn/
103 echo Install and ensure svn.exe makes it into your PATH, default is "C:\Program Files (x86)\Subversion\bin"
104 set errorCode=1
105 )
106
Cody Northrop5934a882015-05-12 16:23:59 -0600107 for %%X in (wget.exe) do (set FOUND=%%~$PATH:X)
108 if not defined FOUND (
109 echo Dependency check failed:
110 echo wget.exe not found
111 echo Get wget for Windows here: http://gnuwin32.sourceforge.net/packages/wget.htm
112 echo Easiest to select "Complete package, except sources" link which will install and setup PATH
113 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\GnuWin32\bin"
114 set errorCode=1
115 )
116
117 for %%X in (gzip.exe) do (set FOUND=%%~$PATH:X)
118 if not defined FOUND (
119 echo Dependency check failed:
120 echo gzip.exe not found
121 echo Get gzip for Windows here: http://gnuwin32.sourceforge.net/packages/gzip.htm
122 echo Easiest to select "Complete package, except sources" link which will install and setup PATH
123 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\GnuWin32\bin"
124 set errorCode=1
125 )
126
127 for %%X in (tar.exe) do (set FOUND=%%~$PATH:X)
128 if not defined FOUND (
129 echo Dependency check failed:
130 echo tar.exe not found
131 echo Get tar for Windows here: http://gnuwin32.sourceforge.net/packages/gtar.htm
132 echo Easiest to select Binaries/Setup link which will install and setup PATH
133 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\GnuWin32\bin"
134 set errorCode=1
135 )
136 )
137
138 if %check-glslang-build-dependencies% equ 1 (
139 for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)
140 if not defined FOUND (
141 echo Dependency check failed:
142 echo cmake.exe not found
143 echo Get CNake 2.8 for Windows here: http://www.cmake.org/cmake/resources/software.html
144 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"
145 set errorCode=1
146 )
147 )
148
149 if %check-LunarGLASS-build-dependencies% equ 1 (
150 for %%X in (python.exe) do (set FOUND=%%~$PATH:X)
151 if not defined FOUND (
152 echo Dependency check failed:
153 echo python.exe not found
154 echo Get python 2.7x for Windows here: http://www.python.org/download/releases/2.7.6/
155 echo Install and ensure each makes it into your PATH, default is "C:\Python27"
156 set errorCode=1
157 )
158
159 for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)
160 if not defined FOUND (
161 echo Dependency check failed:
162 echo cmake.exe not found
163 echo Get CNake 2.8 for Windows here: http://www.cmake.org/cmake/resources/software.html
164 echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"
165 set errorCode=1
166 )
167 )
168
169 REM goto:main
170
171REM // ======== end Dependency checking ======== //
172
173:main
174
175if %errorCode% neq 0 (goto:error)
176
177REM Read the target versions from external file, which is shared with Linux script
178if not exist LunarGLASS_revision (
179 echo.
180 echo Missing LunarGLASS_revision file! Place it next to this script with target version in it.
181 set errorCode=1
182 goto:error
183)
184
185if not exist glslang_revision (
186 echo.
187 echo Missing glslang_revision file! Place it next to this script with target version in it.
188 set errorCode=1
189 goto:error
190)
191
192set /p LUNARGLASS_REVISION= < LunarGLASS_revision
193set /p GLSLANG_REVISION= < glslang_revision
194echo LUNARGLASS_REVISION=%LUNARGLASS_REVISION%
195echo GLSLANG_REVISION=%GLSLANG_REVISION%
196
197echo Creating and/or updating glslang and LunarGLASS in %BASE_DIR%
198
199if %sync-glslang% equ 1 (
200 if not exist %GLSLANG_DIR% (
201 call:create_glslang
202 )
203 if %errorCode% neq 0 (goto:error)
204 call:update_glslang
205 if %errorCode% neq 0 (goto:error)
206)
207
208if %sync-LunarGLASS% equ 1 (
209 if not exist %LUNARGLASS_DIR% (
210 call:create_LunarGLASS
211 )
212 if %errorCode% neq 0 (goto:error)
213 call:update_LunarGLASS
214 if %errorCode% neq 0 (goto:error)
215)
216
217if %build-glslang% equ 1 (
218 call:build_glslang
219 if %errorCode% neq 0 (goto:error)
220)
221
222if %build-LunarGLASS% equ 1 (
223 call:build_LunarGLASS
224 if %errorCode% neq 0 (goto:error)
225)
226
227REM If we made it here, we are golden
228echo.
229echo Success
230goto:finish
231
232:error
233echo.
234echo Halting due to error
235goto:finish
236
237:finish
238if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
239endlocal
240goto:eof
241
242
243
244REM // ======== Functions ======== //
245
246:create_glslang
247 REM Windows complains if it can't find the directory below, no need to call
248 REM rd /S /Q %GLSLANG_DIR%
249 echo.
250 echo Creating local glslang repository %GLSLANG_DIR%)
251 mkdir %GLSLANG_DIR%
252 cd %GLSLANG_DIR%
Cody Northropf91add82015-07-02 11:33:41 -0600253 git clone https://github.com/KhronosGroup/glslang.git .
254 git checkout %GLSLANG_REVISION%
Cody Northrop5934a882015-05-12 16:23:59 -0600255 if not exist %GLSLANG_DIR%\SPIRV (
256 echo glslang source download failed!
257 set errorCode=1
258 )
259goto:eof
260
261:update_glslang
262 echo.
263 echo Updating %GLSLANG_DIR%
264 cd %GLSLANG_DIR%
Cody Northropf91add82015-07-02 11:33:41 -0600265 git checkout %GLSLANG_REVISION%
Cody Northrop5934a882015-05-12 16:23:59 -0600266goto:eof
267
268:create_LunarGLASS
269 REM Windows complains if it can't find the directory below, no need to call
270 REM rd /S /Q %LUNARGLASS_DIR%
271 echo.
272 echo Creating local LunarGLASS repository %LUNARGLASS_DIR%)
273 mkdir %LUNARGLASS_DIR%\Core\LLVM
274 cd %LUNARGLASS_DIR%\Core\LLVM
275 echo.
276 echo Downloading LLVM archive...
277 wget http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz
278 REM tar on windows can't filter through gzip, so the below line doesn't work
279 REM tar --gzip -xf llvm-3.4.src.tar.gz
280 echo.
281 echo Unzipping the archive...
282 echo gzip --decompress --verbose --keep llvm-3.4.src.tar.gz
283 gzip --decompress --verbose --keep llvm-3.4.src.tar.gz
284 echo.
285 echo Extracting the archive... (this is slow)
286 echo tar -xf llvm-3.4.src.tar
287 tar -xf llvm-3.4.src.tar
288 if not exist %LUNARGLASS_DIR%\Core\LLVM\llvm-3.4\lib (
289 echo .
290 echo LLVM source download failed!
291 echo Delete LunarGLASS directory and try again
292 set errorCode=1
293 goto:eof
294 )
295 echo.
296 echo Syncing LunarGLASS source...
297 cd %LUNARGLASS_DIR%
298 svn checkout --force https://lunarglass.googlecode.com/svn/trunk/ .
299 svn revert --depth=infinity .
300 if not exist %LUNARGLASS_DIR%\Frontends\SPIRV (
301 echo.
302 echo LunarGLASS source download failed!
303 set errorCode=1
304 )
305goto:eof
306
307:update_LunarGLASS
308 echo.
309 echo Updating %LUNARGLASS_DIR%
310 cd %LUNARGLASS_DIR%
311 svn update -r %LUNARGLASS_REVISION%
312 REM Just in case we are moving backward, do a revert
313 svn revert -R .
314goto:eof
315
316:build_glslang
317 echo.
318 echo Building %GLSLANG_DIR%
319 cd %GLSLANG_DIR%
320 mkdir build
321 set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
322 cd %GLSLANG_BUILD_DIR%
323 cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
324 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
325 REM Check for existence of one lib, even though we should check for all results
326 if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
327 echo.
328 echo glslang Release build failed!
329 set errorCode=1
330 )
331 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
332 REM Check for existence of one lib, even though we should check for all results
333 if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslang.lib (
334 echo.
335 echo glslang Debug build failed!
336 set errorCode=1
337 )
338goto:eof
339
340:build_LunarGLASS
341 echo.
342 echo Building %LUNARGLASS_DIR%
343 set LLVM_DIR=%LUNARGLASS_DIR%\Core\LLVM\llvm-3.4
344 cd %LLVM_DIR%
345 mkdir build
346 set LLVM_BUILD_DIR=%LLVM_DIR%\build
347 cd %LLVM_BUILD_DIR%
348 cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
349 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
350 REM Check for existence of one lib, even though we should check for all results
351 if not exist %LLVM_BUILD_DIR%\lib\Release\LLVMCore.lib (
352 echo.
353 echo LLVM Release build failed!
354 set errorCode=1
355 goto:eof
356 )
357 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
358 REM Check for existence of one lib, even though we should check for all results
359 if not exist %LLVM_BUILD_DIR%\lib\Debug\LLVMCore.lib (
360 echo.
361 echo LLVM Debug build failed!
362 set errorCode=1
363 goto:eof
364 )
365 cd %LUNARGLASS_DIR%
366 mkdir build
367 set LUNARGLASS_BUILD_DIR=%LUNARGLASS_DIR%\build
368 cd %LUNARGLASS_BUILD_DIR%
369 cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
370 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
371 REM Check for existence of one lib, even though we should check for all results
372 if not exist %LUNARGLASS_BUILD_DIR%\Core\Release\core.lib (
373 echo.
374 echo LunarGLASS build failed!
375 set errorCode=1
376 goto:eof
377 )
378 msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
379 REM Check for existence of one lib, even though we should check for all results
380 if not exist %LUNARGLASS_BUILD_DIR%\Core\Debug\core.lib (
381 echo.
382 echo LunarGLASS build failed!
383 set errorCode=1
384 goto:eof
385 )
386goto:eof