Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 1 | @echo off
|
| 2 | REM Update source for glslang (and eventually LunarGLASS)
|
| 3 |
|
| 4 | setlocal EnableDelayedExpansion
|
| 5 | set errorCode=0
|
| 6 | set BUILD_DIR=%~dp0
|
| 7 | set BASE_DIR=%BUILD_DIR%..
|
| 8 | set GLSLANG_DIR=%BASE_DIR%\glslang
|
| 9 | set LUNARGLASS_DIR=%BASE_DIR%\LunarGLASS
|
| 10 |
|
| 11 | REM // ======== 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 Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 29 | set check-glslang-build-dependencies=0
|
Cody Northrop | f91add8 | 2015-07-02 11:33:41 -0600 | [diff] [blame] | 30 | set check-LunarGLASS-fetch-dependencies=0
|
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 31 | 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 Northrop | f91add8 | 2015-07-02 11:33:41 -0600 | [diff] [blame] | 45 | set check-LunarGLASS-fetch-dependencies=1
|
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 46 | 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 Northrop | f91add8 | 2015-07-02 11:33:41 -0600 | [diff] [blame] | 60 | set check-LunarGLASS-fetch-dependencies=1
|
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 61 | 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 Northrop | f91add8 | 2015-07-02 11:33:41 -0600 | [diff] [blame] | 72 | set check-LunarGLASS-fetch-dependencies=1
|
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 73 | 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 |
|
| 84 | REM // ======== end Parameter parsing ======== //
|
| 85 |
|
| 86 |
|
| 87 | REM // ======== Dependency checking ======== //
|
Cody Northrop | f91add8 | 2015-07-02 11:33:41 -0600 | [diff] [blame] | 88 | for %%X in (git.exe) do (set FOUND=%%~$PATH:X)
|
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 89 | if not defined FOUND (
|
| 90 | echo Dependency check failed:
|
Cody Northrop | f91add8 | 2015-07-02 11:33:41 -0600 | [diff] [blame] | 91 | echo git.exe not found
|
| 92 | echo Install and ensure git.exe makes it into your PATH
|
| 93 |
|
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 94 | set errorCode=1
|
| 95 | )
|
| 96 |
|
Cody Northrop | f91add8 | 2015-07-02 11:33:41 -0600 | [diff] [blame] | 97 | 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 Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 107 | 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 |
|
| 171 | REM // ======== end Dependency checking ======== //
|
| 172 |
|
| 173 | :main
|
| 174 |
|
| 175 | if %errorCode% neq 0 (goto:error)
|
| 176 |
|
| 177 | REM Read the target versions from external file, which is shared with Linux script
|
| 178 | if 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 |
|
| 185 | if 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 |
|
| 192 | set /p LUNARGLASS_REVISION= < LunarGLASS_revision
|
| 193 | set /p GLSLANG_REVISION= < glslang_revision
|
| 194 | echo LUNARGLASS_REVISION=%LUNARGLASS_REVISION%
|
| 195 | echo GLSLANG_REVISION=%GLSLANG_REVISION%
|
| 196 |
|
| 197 | echo Creating and/or updating glslang and LunarGLASS in %BASE_DIR%
|
| 198 |
|
| 199 | if %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 |
|
| 208 | if %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 |
|
| 217 | if %build-glslang% equ 1 (
|
| 218 | call:build_glslang
|
| 219 | if %errorCode% neq 0 (goto:error)
|
| 220 | )
|
| 221 |
|
| 222 | if %build-LunarGLASS% equ 1 (
|
| 223 | call:build_LunarGLASS
|
| 224 | if %errorCode% neq 0 (goto:error)
|
| 225 | )
|
| 226 |
|
| 227 | REM If we made it here, we are golden
|
| 228 | echo.
|
| 229 | echo Success
|
| 230 | goto:finish
|
| 231 |
|
| 232 | :error
|
| 233 | echo.
|
| 234 | echo Halting due to error
|
| 235 | goto:finish
|
| 236 |
|
| 237 | :finish
|
| 238 | if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
|
| 239 | endlocal
|
| 240 | goto:eof
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 | REM // ======== 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 Northrop | f91add8 | 2015-07-02 11:33:41 -0600 | [diff] [blame] | 253 | git clone https://github.com/KhronosGroup/glslang.git .
|
| 254 | git checkout %GLSLANG_REVISION%
|
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 255 | if not exist %GLSLANG_DIR%\SPIRV (
|
| 256 | echo glslang source download failed!
|
| 257 | set errorCode=1
|
| 258 | )
|
| 259 | goto:eof
|
| 260 |
|
| 261 | :update_glslang
|
| 262 | echo.
|
| 263 | echo Updating %GLSLANG_DIR%
|
| 264 | cd %GLSLANG_DIR%
|
Cody Northrop | 5a4883b | 2015-07-08 09:53:03 -0600 | [diff] [blame] | 265 | git fetch --all
|
Cody Northrop | f91add8 | 2015-07-02 11:33:41 -0600 | [diff] [blame] | 266 | git checkout %GLSLANG_REVISION%
|
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 267 | goto:eof
|
| 268 |
|
| 269 | :create_LunarGLASS
|
| 270 | REM Windows complains if it can't find the directory below, no need to call
|
| 271 | REM rd /S /Q %LUNARGLASS_DIR%
|
| 272 | echo.
|
| 273 | echo Creating local LunarGLASS repository %LUNARGLASS_DIR%)
|
| 274 | mkdir %LUNARGLASS_DIR%\Core\LLVM
|
| 275 | cd %LUNARGLASS_DIR%\Core\LLVM
|
| 276 | echo.
|
| 277 | echo Downloading LLVM archive...
|
| 278 | wget http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz
|
| 279 | REM tar on windows can't filter through gzip, so the below line doesn't work
|
| 280 | REM tar --gzip -xf llvm-3.4.src.tar.gz
|
| 281 | echo.
|
| 282 | echo Unzipping the archive...
|
| 283 | echo gzip --decompress --verbose --keep llvm-3.4.src.tar.gz
|
| 284 | gzip --decompress --verbose --keep llvm-3.4.src.tar.gz
|
| 285 | echo.
|
| 286 | echo Extracting the archive... (this is slow)
|
| 287 | echo tar -xf llvm-3.4.src.tar
|
| 288 | tar -xf llvm-3.4.src.tar
|
| 289 | if not exist %LUNARGLASS_DIR%\Core\LLVM\llvm-3.4\lib (
|
| 290 | echo .
|
| 291 | echo LLVM source download failed!
|
| 292 | echo Delete LunarGLASS directory and try again
|
| 293 | set errorCode=1
|
| 294 | goto:eof
|
| 295 | )
|
| 296 | echo.
|
| 297 | echo Syncing LunarGLASS source...
|
| 298 | cd %LUNARGLASS_DIR%
|
| 299 | svn checkout --force https://lunarglass.googlecode.com/svn/trunk/ .
|
| 300 | svn revert --depth=infinity .
|
| 301 | if not exist %LUNARGLASS_DIR%\Frontends\SPIRV (
|
| 302 | echo.
|
| 303 | echo LunarGLASS source download failed!
|
| 304 | set errorCode=1
|
| 305 | )
|
| 306 | goto:eof
|
| 307 |
|
| 308 | :update_LunarGLASS
|
| 309 | echo.
|
| 310 | echo Updating %LUNARGLASS_DIR%
|
| 311 | cd %LUNARGLASS_DIR%
|
| 312 | svn update -r %LUNARGLASS_REVISION%
|
| 313 | REM Just in case we are moving backward, do a revert
|
| 314 | svn revert -R .
|
| 315 | goto:eof
|
| 316 |
|
| 317 | :build_glslang
|
| 318 | echo.
|
| 319 | echo Building %GLSLANG_DIR%
|
| 320 | cd %GLSLANG_DIR%
|
| 321 | mkdir build
|
| 322 | set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
|
| 323 | cd %GLSLANG_BUILD_DIR%
|
| 324 | cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
|
| 325 | msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
|
| 326 | REM Check for existence of one lib, even though we should check for all results
|
| 327 | if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
|
| 328 | echo.
|
| 329 | echo glslang Release build failed!
|
| 330 | set errorCode=1
|
| 331 | )
|
| 332 | msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
|
| 333 | REM Check for existence of one lib, even though we should check for all results
|
| 334 | if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslang.lib (
|
| 335 | echo.
|
| 336 | echo glslang Debug build failed!
|
| 337 | set errorCode=1
|
| 338 | )
|
| 339 | goto:eof
|
| 340 |
|
| 341 | :build_LunarGLASS
|
| 342 | echo.
|
| 343 | echo Building %LUNARGLASS_DIR%
|
| 344 | set LLVM_DIR=%LUNARGLASS_DIR%\Core\LLVM\llvm-3.4
|
| 345 | cd %LLVM_DIR%
|
| 346 | mkdir build
|
| 347 | set LLVM_BUILD_DIR=%LLVM_DIR%\build
|
| 348 | cd %LLVM_BUILD_DIR%
|
| 349 | cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
|
| 350 | msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
|
| 351 | REM Check for existence of one lib, even though we should check for all results
|
| 352 | if not exist %LLVM_BUILD_DIR%\lib\Release\LLVMCore.lib (
|
| 353 | echo.
|
| 354 | echo LLVM Release build failed!
|
| 355 | set errorCode=1
|
| 356 | goto:eof
|
| 357 | )
|
| 358 | msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
|
| 359 | REM Check for existence of one lib, even though we should check for all results
|
| 360 | if not exist %LLVM_BUILD_DIR%\lib\Debug\LLVMCore.lib (
|
| 361 | echo.
|
| 362 | echo LLVM Debug build failed!
|
| 363 | set errorCode=1
|
| 364 | goto:eof
|
| 365 | )
|
| 366 | cd %LUNARGLASS_DIR%
|
| 367 | mkdir build
|
| 368 | set LUNARGLASS_BUILD_DIR=%LUNARGLASS_DIR%\build
|
| 369 | cd %LUNARGLASS_BUILD_DIR%
|
| 370 | cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
|
| 371 | msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
|
| 372 | REM Check for existence of one lib, even though we should check for all results
|
| 373 | if not exist %LUNARGLASS_BUILD_DIR%\Core\Release\core.lib (
|
| 374 | echo.
|
| 375 | echo LunarGLASS build failed!
|
| 376 | set errorCode=1
|
| 377 | goto:eof
|
| 378 | )
|
| 379 | msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
|
| 380 | REM Check for existence of one lib, even though we should check for all results
|
| 381 | if not exist %LUNARGLASS_BUILD_DIR%\Core\Debug\core.lib (
|
| 382 | echo.
|
| 383 | echo LunarGLASS build failed!
|
| 384 | set errorCode=1
|
| 385 | goto:eof
|
| 386 | )
|
| 387 | goto:eof
|