--- /dev/null
+@echo off\r
+REM Update source for glslang (and eventually LunarGLASS)\r
+\r
+setlocal EnableDelayedExpansion\r
+set errorCode=0\r
+set BUILD_DIR=%~dp0\r
+set BASE_DIR=%BUILD_DIR%..\r
+set GLSLANG_DIR=%BASE_DIR%\glslang\r
+set LUNARGLASS_DIR=%BASE_DIR%\LunarGLASS\r
+\r
+REM // ======== Parameter parsing ======== //\r
+\r
+ if "%1" == "" (\r
+ echo usage: update_external_sources.bat [options]\r
+ echo.\r
+ echo Available options:\r
+ echo --sync-glslang just pull glslang_revision\r
+ echo --sync-LunarGLASS just pull LunarGLASS_revision\r
+ echo --build-glslang pulls glslang_revision, configures CMake, builds Release and Debug\r
+ echo --build-LunarGLASS pulls LunarGLASS_revision, configures CMake, builds Release and Debug\r
+ echo --all sync and build both glslang and LunarGLASS\r
+ goto:finish\r
+ )\r
+\r
+ set sync-glslang=0\r
+ set sync-LunarGLASS=0\r
+ set build-glslang=0\r
+ set build-LunarGLASS=0\r
+ set check-fetch-dependencies=0\r
+ set check-glslang-build-dependencies=0\r
+ set check-LunarGLASS-build-dependencies=0\r
+\r
+ :parameterLoop\r
+\r
+ if "%1"=="" goto:parameterContinue\r
+\r
+ if "%1" == "--sync-glslang" (\r
+ set sync-glslang=1\r
+ shift\r
+ goto:parameterLoop\r
+ )\r
+\r
+ if "%1" == "--sync-LunarGLASS" (\r
+ set sync-LunarGLASS=1\r
+ set check-fetch-dependencies=1\r
+ shift\r
+ goto:parameterLoop\r
+ )\r
+\r
+ if "%1" == "--build-glslang" (\r
+ set sync-glslang=1\r
+ set check-glslang-build-dependencies=1\r
+ set build-glslang=1\r
+ shift\r
+ goto:parameterLoop\r
+ )\r
+\r
+ if "%1" == "--build-LunarGLASS" (\r
+ set sync-LunarGLASS=1\r
+ set check-fetch-dependencies=1\r
+ set check-LunarGLASS-build-dependencies=1\r
+ set build-LunarGLASS=1\r
+ shift\r
+ goto:parameterLoop\r
+ )\r
+\r
+ if "%1" == "--all" (\r
+ set sync-glslang=1\r
+ set sync-LunarGLASS=1\r
+ set build-glslang=1\r
+ set build-LunarGLASS=1\r
+ set check-fetch-dependencies=1\r
+ set check-glslang-build-dependencies=1\r
+ set check-LunarGLASS-build-dependencies=1\r
+ shift\r
+ goto:parameterLoop\r
+ )\r
+\r
+ echo Unrecognized options "%1"\r
+ goto:error\r
+\r
+ :parameterContinue\r
+\r
+REM // ======== end Parameter parsing ======== //\r
+\r
+\r
+REM // ======== Dependency checking ======== //\r
+\r
+ for %%X in (svn.exe) do (set FOUND=%%~$PATH:X)\r
+ if not defined FOUND (\r
+ echo Dependency check failed:\r
+ echo svn.exe not found\r
+ echo Get Subversion for Windows here: http://sourceforge.net/projects/win32svn/\r
+ echo Install and ensure the svn.exe makes it into your PATH, default is "C:\Program Files (x86)\Subversion\bin"\r
+ set errorCode=1\r
+ )\r
+\r
+ if %check-fetch-dependencies% equ 1 (\r
+ for %%X in (wget.exe) do (set FOUND=%%~$PATH:X)\r
+ if not defined FOUND (\r
+ echo Dependency check failed:\r
+ echo wget.exe not found\r
+ echo Get wget for Windows here: http://gnuwin32.sourceforge.net/packages/wget.htm\r
+ echo Easiest to select "Complete package, except sources" link which will install and setup PATH\r
+ echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\GnuWin32\bin"\r
+ set errorCode=1\r
+ )\r
+\r
+ for %%X in (gzip.exe) do (set FOUND=%%~$PATH:X)\r
+ if not defined FOUND (\r
+ echo Dependency check failed:\r
+ echo gzip.exe not found\r
+ echo Get gzip for Windows here: http://gnuwin32.sourceforge.net/packages/gzip.htm\r
+ echo Easiest to select "Complete package, except sources" link which will install and setup PATH\r
+ echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\GnuWin32\bin"\r
+ set errorCode=1\r
+ )\r
+\r
+ for %%X in (tar.exe) do (set FOUND=%%~$PATH:X)\r
+ if not defined FOUND (\r
+ echo Dependency check failed:\r
+ echo tar.exe not found\r
+ echo Get tar for Windows here: http://gnuwin32.sourceforge.net/packages/gtar.htm\r
+ echo Easiest to select Binaries/Setup link which will install and setup PATH\r
+ echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\GnuWin32\bin"\r
+ set errorCode=1\r
+ )\r
+ )\r
+\r
+ if %check-glslang-build-dependencies% equ 1 (\r
+ for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)\r
+ if not defined FOUND (\r
+ echo Dependency check failed:\r
+ echo cmake.exe not found\r
+ echo Get CNake 2.8 for Windows here: http://www.cmake.org/cmake/resources/software.html\r
+ echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"\r
+ set errorCode=1\r
+ )\r
+ )\r
+\r
+ if %check-LunarGLASS-build-dependencies% equ 1 (\r
+ for %%X in (python.exe) do (set FOUND=%%~$PATH:X)\r
+ if not defined FOUND (\r
+ echo Dependency check failed:\r
+ echo python.exe not found\r
+ echo Get python 2.7x for Windows here: http://www.python.org/download/releases/2.7.6/\r
+ echo Install and ensure each makes it into your PATH, default is "C:\Python27"\r
+ set errorCode=1\r
+ )\r
+\r
+ for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)\r
+ if not defined FOUND (\r
+ echo Dependency check failed:\r
+ echo cmake.exe not found\r
+ echo Get CNake 2.8 for Windows here: http://www.cmake.org/cmake/resources/software.html\r
+ echo Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"\r
+ set errorCode=1\r
+ )\r
+ )\r
+\r
+ REM goto:main\r
+\r
+REM // ======== end Dependency checking ======== //\r
+\r
+:main\r
+\r
+if %errorCode% neq 0 (goto:error)\r
+\r
+REM Read the target versions from external file, which is shared with Linux script\r
+if not exist LunarGLASS_revision (\r
+ echo.\r
+ echo Missing LunarGLASS_revision file! Place it next to this script with target version in it.\r
+ set errorCode=1\r
+ goto:error\r
+)\r
+\r
+if not exist glslang_revision (\r
+ echo.\r
+ echo Missing glslang_revision file! Place it next to this script with target version in it.\r
+ set errorCode=1\r
+ goto:error\r
+)\r
+\r
+set /p LUNARGLASS_REVISION= < LunarGLASS_revision\r
+set /p GLSLANG_REVISION= < glslang_revision\r
+echo LUNARGLASS_REVISION=%LUNARGLASS_REVISION%\r
+echo GLSLANG_REVISION=%GLSLANG_REVISION%\r
+\r
+echo Creating and/or updating glslang and LunarGLASS in %BASE_DIR%\r
+\r
+if %sync-glslang% equ 1 (\r
+ if not exist %GLSLANG_DIR% (\r
+ call:create_glslang\r
+ )\r
+ if %errorCode% neq 0 (goto:error)\r
+ call:update_glslang\r
+ if %errorCode% neq 0 (goto:error)\r
+)\r
+\r
+if %sync-LunarGLASS% equ 1 (\r
+ if not exist %LUNARGLASS_DIR% (\r
+ call:create_LunarGLASS\r
+ )\r
+ if %errorCode% neq 0 (goto:error)\r
+ call:update_LunarGLASS\r
+ if %errorCode% neq 0 (goto:error)\r
+)\r
+\r
+if %build-glslang% equ 1 (\r
+ call:build_glslang\r
+ if %errorCode% neq 0 (goto:error)\r
+)\r
+\r
+if %build-LunarGLASS% equ 1 (\r
+ call:build_LunarGLASS\r
+ if %errorCode% neq 0 (goto:error)\r
+)\r
+\r
+REM If we made it here, we are golden\r
+echo.\r
+echo Success\r
+goto:finish\r
+\r
+:error\r
+echo.\r
+echo Halting due to error\r
+goto:finish\r
+\r
+:finish\r
+if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )\r
+endlocal\r
+goto:eof\r
+\r
+\r
+\r
+REM // ======== Functions ======== //\r
+\r
+:create_glslang\r
+ REM Windows complains if it can't find the directory below, no need to call\r
+ REM rd /S /Q %GLSLANG_DIR%\r
+ echo.\r
+ echo Creating local glslang repository %GLSLANG_DIR%)\r
+ mkdir %GLSLANG_DIR%\r
+ cd %GLSLANG_DIR%\r
+ svn checkout https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@%GLSLANG_REVISION% .\r
+ if not exist %GLSLANG_DIR%\SPIRV (\r
+ echo glslang source download failed!\r
+ set errorCode=1\r
+ )\r
+goto:eof\r
+\r
+:update_glslang\r
+ echo.\r
+ echo Updating %GLSLANG_DIR%\r
+ cd %GLSLANG_DIR%\r
+ svn update -r %GLSLANG_REVISION%\r
+ REM Just in case we are moving backward, do a revert\r
+ svn revert -R .\r
+goto:eof\r
+\r
+:create_LunarGLASS\r
+ REM Windows complains if it can't find the directory below, no need to call\r
+ REM rd /S /Q %LUNARGLASS_DIR%\r
+ echo.\r
+ echo Creating local LunarGLASS repository %LUNARGLASS_DIR%)\r
+ mkdir %LUNARGLASS_DIR%\Core\LLVM\r
+ cd %LUNARGLASS_DIR%\Core\LLVM\r
+ echo.\r
+ echo Downloading LLVM archive...\r
+ wget http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz\r
+ REM tar on windows can't filter through gzip, so the below line doesn't work\r
+ REM tar --gzip -xf llvm-3.4.src.tar.gz\r
+ echo.\r
+ echo Unzipping the archive...\r
+ echo gzip --decompress --verbose --keep llvm-3.4.src.tar.gz\r
+ gzip --decompress --verbose --keep llvm-3.4.src.tar.gz\r
+ echo.\r
+ echo Extracting the archive... (this is slow)\r
+ echo tar -xf llvm-3.4.src.tar\r
+ tar -xf llvm-3.4.src.tar\r
+ if not exist %LUNARGLASS_DIR%\Core\LLVM\llvm-3.4\lib (\r
+ echo .\r
+ echo LLVM source download failed!\r
+ echo Delete LunarGLASS directory and try again\r
+ set errorCode=1\r
+ goto:eof\r
+ )\r
+ echo.\r
+ echo Syncing LunarGLASS source...\r
+ cd %LUNARGLASS_DIR%\r
+ svn checkout --force https://lunarglass.googlecode.com/svn/trunk/ .\r
+ svn revert --depth=infinity .\r
+ if not exist %LUNARGLASS_DIR%\Frontends\SPIRV (\r
+ echo.\r
+ echo LunarGLASS source download failed!\r
+ set errorCode=1\r
+ )\r
+goto:eof\r
+\r
+:update_LunarGLASS\r
+ echo.\r
+ echo Updating %LUNARGLASS_DIR%\r
+ cd %LUNARGLASS_DIR%\r
+ svn update -r %LUNARGLASS_REVISION%\r
+ REM Just in case we are moving backward, do a revert\r
+ svn revert -R .\r
+goto:eof\r
+\r
+:build_glslang\r
+ echo.\r
+ echo Building %GLSLANG_DIR%\r
+ cd %GLSLANG_DIR%\r
+ mkdir build\r
+ set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build\r
+ cd %GLSLANG_BUILD_DIR%\r
+ cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..\r
+ msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release\r
+ REM Check for existence of one lib, even though we should check for all results\r
+ if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (\r
+ echo.\r
+ echo glslang Release build failed!\r
+ set errorCode=1\r
+ )\r
+ msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug\r
+ REM Check for existence of one lib, even though we should check for all results\r
+ if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslang.lib (\r
+ echo.\r
+ echo glslang Debug build failed!\r
+ set errorCode=1\r
+ )\r
+goto:eof\r
+\r
+:build_LunarGLASS\r
+ echo.\r
+ echo Building %LUNARGLASS_DIR%\r
+ set LLVM_DIR=%LUNARGLASS_DIR%\Core\LLVM\llvm-3.4\r
+ cd %LLVM_DIR%\r
+ mkdir build\r
+ set LLVM_BUILD_DIR=%LLVM_DIR%\build\r
+ cd %LLVM_BUILD_DIR%\r
+ cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..\r
+ msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release\r
+ REM Check for existence of one lib, even though we should check for all results\r
+ if not exist %LLVM_BUILD_DIR%\lib\Release\LLVMCore.lib (\r
+ echo.\r
+ echo LLVM Release build failed!\r
+ set errorCode=1\r
+ goto:eof\r
+ )\r
+ msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug\r
+ REM Check for existence of one lib, even though we should check for all results\r
+ if not exist %LLVM_BUILD_DIR%\lib\Debug\LLVMCore.lib (\r
+ echo.\r
+ echo LLVM Debug build failed!\r
+ set errorCode=1\r
+ goto:eof\r
+ )\r
+ cd %LUNARGLASS_DIR%\r
+ mkdir build\r
+ set LUNARGLASS_BUILD_DIR=%LUNARGLASS_DIR%\build\r
+ cd %LUNARGLASS_BUILD_DIR%\r
+ cmake -G"Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..\r
+ msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release\r
+ REM Check for existence of one lib, even though we should check for all results\r
+ if not exist %LUNARGLASS_BUILD_DIR%\Core\Release\core.lib (\r
+ echo.\r
+ echo LunarGLASS build failed!\r
+ set errorCode=1\r
+ goto:eof\r
+ )\r
+ msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug\r
+ REM Check for existence of one lib, even though we should check for all results\r
+ if not exist %LUNARGLASS_BUILD_DIR%\Core\Debug\core.lib (\r
+ echo.\r
+ echo LunarGLASS build failed!\r
+ set errorCode=1\r
+ goto:eof\r
+ )\r
+goto:eof\r