1@echo off 2REM Update source for glslang, spirv-tools, and shaderc 3 4REM 5REM Copyright 2016 The Android Open Source Project 6REM Copyright (C) 2015 Valve Corporation 7REM 8REM Licensed under the Apache License, Version 2.0 (the "License"); 9REM you may not use this file except in compliance with the License. 10REM You may obtain a copy of the License at 11REM 12REM http://www.apache.org/licenses/LICENSE-2.0 13REM 14REM Unless required by applicable law or agreed to in writing, software 15REM distributed under the License is distributed on an "AS IS" BASIS, 16REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17REM See the License for the specific language governing permissions and 18REM limitations under the License. 19REM 20 21setlocal EnableDelayedExpansion 22set errorCode=0 23set ANDROID_BUILD_DIR=%~dp0 24set BUILD_DIR=%ANDROID_BUILD_DIR% 25set BASE_DIR=%BUILD_DIR%\third_party 26set GLSLANG_DIR=%BASE_DIR%\shaderc\third_party\glslang 27set SPIRV_TOOLS_DIR=%BASE_DIR%\shaderc\third_party\spirv-tools 28set SPIRV_HEADERS_DIR=%BASE_DIR%\shaderc\third_party\spirv-tools\external\spirv-headers 29set SHADERC_DIR=%BASE_DIR%\shaderc 30 31for %%X in (where.exe) do (set FOUND=%%~$PATH:X) 32if not defined FOUND ( 33 echo Dependency check failed: 34 echo where.exe not found 35 echo This script requires Windows Vista or later, which includes where.exe. 36 set errorCode=1 37) 38 39where /q git.exe 40if %ERRORLEVEL% equ 1 ( 41 echo Dependency check failed: 42 echo git.exe not found 43 echo Git for Windows can be downloaded here: https://git-scm.com/download/win 44 echo Install and ensure git.exe makes it into your PATH 45 set errorCode=1 46) 47 48where /q ndk-build.cmd 49if %ERRORLEVEL% equ 1 ( 50 echo Dependency check failed: 51 echo ndk-build.cmd not found 52 echo Android NDK can be downloaded here: http://developer.android.com/ndk/guides/setup.html 53 echo Install and ensure ndk-build.cmd makes it into your PATH 54 set errorCode=1 55) 56 57REM ensure where is working with below false test 58REM where /q foo 59REM if %ERRORLEVEL% equ 1 ( 60REM echo foo 61REM ) 62 63:main 64 65if %errorCode% neq 0 (goto:error) 66 67REM Read the target versions from external file, which is shared with Linux script 68 69if not exist %ANDROID_BUILD_DIR%\glslang_revision_android ( 70 echo. 71 echo Missing glslang_revision_android file. Place it in %ANDROID_BUILD_DIR% 72 goto:error 73) 74 75if not exist %ANDROID_BUILD_DIR%\spirv-tools_revision_android ( 76 echo. 77 echo Missing spirv-tools_revision_android file. Place it in %ANDROID_BUILD_DIR% 78 set errorCode=1 79 goto:error 80) 81 82if not exist %ANDROID_BUILD_DIR%\spirv-headers_revision_android ( 83 echo. 84 echo Missing spirv-headers_revision_android file. Place it in %ANDROID_BUILD_DIR% 85 set errorCode=1 86 goto:error 87) 88 89if not exist %ANDROID_BUILD_DIR%\shaderc_revision_android ( 90 echo. 91 echo Missing shaderc_revision_android file. Place it in %ANDROID_BUILD_DIR% 92 set errorCode=1 93 goto:error 94) 95 96set /p GLSLANG_REVISION= < glslang_revision_android 97set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision_android 98set /p SPIRV_HEADERS_REVISION= < spirv-headers_revision_android 99set /p SHADERC_REVISION= < shaderc_revision_android 100echo GLSLANG_REVISION=%GLSLANG_REVISION% 101echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION% 102echo SPIRV_HEADERS_REVISION=%SPIRV_HEADERS_REVISION% 103echo SHADERC_REVISION=%SHADERC_REVISION% 104 105 106echo Creating and/or updating glslang, spirv-tools, spirv-headers, shaderc in %BASE_DIR% 107 108set sync-glslang=1 109set sync-spirv-tools=1 110set sync-spirv-headers=1 111set sync-shaderc=1 112set build-shaderc=1 113 114if %sync-shaderc% equ 1 ( 115 if not exist %SHADERC_DIR% ( 116 call:create_shaderc 117 ) 118 if %errorCode% neq 0 (goto:error) 119 call:update_shaderc 120 if %errorCode% neq 0 (goto:error) 121) 122 123if %sync-glslang% equ 1 ( 124 if not exist %GLSLANG_DIR% ( 125 call:create_glslang 126 ) 127 if %errorCode% neq 0 (goto:error) 128 call:update_glslang 129 if %errorCode% neq 0 (goto:error) 130) 131 132if %sync-spirv-tools% equ 1 ( 133 if %ERRORLEVEL% neq 0 (goto:error) 134 if not exist %SPIRV_TOOLS_DIR% ( 135 call:create_spirv-tools 136 ) 137 if %errorCode% neq 0 (goto:error) 138 call:update_spirv-tools 139 if %errorCode% neq 0 (goto:error) 140) 141 142if %sync-spirv-headers% equ 1 ( 143 if %ERRORLEVEL% neq 0 (goto:error) 144 if not exist %SPIRV_HEADERS_DIR% ( 145 call:create_spirv-headers 146 ) 147 if %errorCode% neq 0 (goto:error) 148 call:update_spirv-headers 149 if %errorCode% neq 0 (goto:error) 150) 151 152if %build-shaderc% equ 1 ( 153 call:build_shaderc 154 if %errorCode% neq 0 (goto:error) 155) 156 157echo. 158echo Exiting 159goto:finish 160 161:error 162echo. 163echo Halting due to error 164goto:finish 165 166:finish 167if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% ) 168endlocal 169REM This needs a fix to return error, something like exit %errorCode% 170REM Right now it is returning 0 171goto:eof 172 173 174 175REM // ======== Functions ======== // 176 177:create_glslang 178 echo. 179 echo Creating local glslang repository %GLSLANG_DIR% 180 if not exist "%GLSLANG_DIR%\" mkdir %GLSLANG_DIR% 181 cd %GLSLANG_DIR% 182 git clone https://github.com/KhronosGroup/glslang.git . 183 git checkout %GLSLANG_REVISION% 184 if not exist %GLSLANG_DIR%\SPIRV ( 185 echo glslang source download failed! 186 set errorCode=1 187 ) 188goto:eof 189 190:update_glslang 191 echo. 192 echo Updating %GLSLANG_DIR% 193 cd %GLSLANG_DIR% 194 git fetch --all 195 git checkout %GLSLANG_REVISION% 196 if not exist %GLSLANG_DIR%\SPIRV ( 197 echo glslang source update failed! 198 set errorCode=1 199 ) 200goto:eof 201 202:create_spirv-tools 203 echo. 204 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR% 205 if not exist "%SPIRV_TOOLS_DIR%\" mkdir %SPIRV_TOOLS_DIR% 206 cd %SPIRV_TOOLS_DIR% 207 git clone https://github.com/KhronosGroup/SPIRV-Tools.git . 208 git checkout %SPIRV_TOOLS_REVISION% 209 if not exist %SPIRV_TOOLS_DIR%\source ( 210 echo spirv-tools source download failed! 211 set errorCode=1 212 ) 213goto:eof 214 215:update_spirv-tools 216 echo. 217 echo Updating %SPIRV_TOOLS_DIR% 218 cd %SPIRV_TOOLS_DIR% 219 git fetch --all 220 git checkout %SPIRV_TOOLS_REVISION% 221 if not exist %SPIRV_TOOLS_DIR%\source ( 222 echo spirv-tools source update failed! 223 set errorCode=1 224 ) 225goto:eof 226 227:create_spirv-headers 228 echo. 229 echo Creating local spirv-headers repository %SPIRV_HEADERS_DIR% 230 if not exist "%SPIRV_HEADERS_DIR%\" mkdir %SPIRV_HEADERS_DIR% 231 cd %SPIRV_HEADERS_DIR% 232 git clone https://github.com/KhronosGroup/SPIRV-Headers.git . 233 git checkout %SPIRV_HEADERS_REVISION% 234 if not exist %SPIRV_HEADERS_DIR%\include ( 235 echo spirv-headers source download failed! 236 set errorCode=1 237 ) 238goto:eof 239 240:update_spirv-headers 241 echo. 242 echo Updating %SPIRV_HEADERS_DIR% 243 cd %SPIRV_HEADERS_DIR% 244 git fetch --all 245 git checkout %SPIRV_HEADERS_REVISION% 246 if not exist %SPIRV_HEADERS_DIR%\include ( 247 echo spirv-headers source update failed! 248 set errorCode=1 249 ) 250goto:eof 251 252:create_shaderc 253 echo. 254 echo Creating local shaderc repository %SHADERC_DIR% 255 if not exist "%SHADERC_DIR%\" mkdir %SHADERC_DIR% 256 cd %SHADERC_DIR% 257 git clone https://github.com/google/shaderc.git . 258 git checkout %SHADERC_REVISION% 259 if not exist %SHADERC_DIR%\libshaderc ( 260 echo shaderc source download failed! 261 set errorCode=1 262 ) 263goto:eof 264 265:update_shaderc 266 echo. 267 echo Updating %SHADERC_DIR% 268 cd %SHADERC_DIR% 269 git fetch --all 270 git checkout %SHADERC_REVISION% 271 if not exist %SHADERC_DIR%\libshaderc ( 272 echo shaderc source update failed! 273 set errorCode=1 274 ) 275goto:eof 276 277:build_shaderc 278 echo. 279 echo Building %SHADERC_DIR% 280 cd %SHADERC_DIR%\android_test 281 echo Building shaderc with Android NDK 282 call ndk-build NDK_APPLICATION_MK=../../../jni/shaderc/Application.mk THIRD_PARTY_PATH=../third_party -j 4 283 REM Check for existence of one lib, even though we should check for all results 284 if not exist %SHADERC_DIR%\android_test\obj\local\x86\libshaderc.a ( 285 echo. 286 echo shaderc build failed! 287 set errorCode=1 288 ) 289goto:eof 290