Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 1 | @echo off |
| 2 | REM Update source for glslang, spirv-tools, and shaderc |
| 3 | |
| 4 | REM |
| 5 | REM Copyright 2016 The Android Open Source Project |
| 6 | REM Copyright (C) 2015 Valve Corporation |
| 7 | REM |
| 8 | REM Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | REM you may not use this file except in compliance with the License. |
| 10 | REM You may obtain a copy of the License at |
| 11 | REM |
| 12 | REM http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | REM |
| 14 | REM Unless required by applicable law or agreed to in writing, software |
| 15 | REM distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | REM See the License for the specific language governing permissions and |
| 18 | REM limitations under the License. |
| 19 | REM |
| 20 | |
| 21 | setlocal EnableDelayedExpansion |
| 22 | set errorCode=0 |
| 23 | set ANDROID_BUILD_DIR=%~dp0 |
Cody Northrop | 544a42e | 2016-11-03 14:44:55 -0600 | [diff] [blame] | 24 | set BUILD_DIR=%ANDROID_BUILD_DIR% |
Cody Northrop | 217d23c | 2016-05-03 15:38:05 -0600 | [diff] [blame] | 25 | set BASE_DIR=%BUILD_DIR%\external |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 26 | set GLSLANG_DIR=%BASE_DIR%\glslang |
| 27 | set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 28 | set SPIRV_HEADERS_DIR=%BASE_DIR%\spirv-tools\external\spirv-headers |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 29 | set SHADERC_DIR=%BASE_DIR%\shaderc |
| 30 | |
| 31 | for %%X in (where.exe) do (set FOUND=%%~$PATH:X) |
| 32 | if 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 | |
| 39 | where /q git.exe |
| 40 | if %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 | |
| 48 | where /q ndk-build.cmd |
| 49 | if %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 | |
| 57 | REM ensure where is working with below false test |
| 58 | REM where /q foo |
| 59 | REM if %ERRORLEVEL% equ 1 ( |
| 60 | REM echo foo |
| 61 | REM ) |
| 62 | |
| 63 | :main |
| 64 | |
| 65 | if %errorCode% neq 0 (goto:error) |
| 66 | |
| 67 | REM Read the target versions from external file, which is shared with Linux script |
| 68 | |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 69 | if not exist %ANDROID_BUILD_DIR%\glslang_revision_android ( |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 70 | echo. |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 71 | echo Missing glslang_revision_android file. Place it in %ANDROID_BUILD_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 72 | goto:error |
| 73 | ) |
| 74 | |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 75 | if not exist %ANDROID_BUILD_DIR%\spirv-tools_revision_android ( |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 76 | echo. |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 77 | echo Missing spirv-tools_revision_android file. Place it in %ANDROID_BUILD_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 78 | set errorCode=1 |
| 79 | goto:error |
| 80 | ) |
| 81 | |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 82 | if 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 | |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 89 | if not exist %ANDROID_BUILD_DIR%\shaderc_revision_android ( |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 90 | echo. |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 91 | echo Missing shaderc_revision_android file. Place it in %ANDROID_BUILD_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 92 | set errorCode=1 |
| 93 | goto:error |
| 94 | ) |
| 95 | |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 96 | set /p GLSLANG_REVISION= < glslang_revision_android |
| 97 | set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision_android |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 98 | set /p SPIRV_HEADERS_REVISION= < spirv-headers_revision_android |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 99 | set /p SHADERC_REVISION= < shaderc_revision_android |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 100 | echo GLSLANG_REVISION=%GLSLANG_REVISION% |
| 101 | echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION% |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 102 | echo SPIRV_HEADERS_REVISION=%SPIRV_HEADERS_REVISION% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 103 | echo SHADERC_REVISION=%SHADERC_REVISION% |
| 104 | |
| 105 | |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 106 | echo Creating and/or updating glslang, spirv-tools, spirv-headers, shaderc in %BASE_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 107 | |
| 108 | set sync-glslang=1 |
| 109 | set sync-spirv-tools=1 |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 110 | set sync-spirv-headers=1 |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 111 | set sync-shaderc=1 |
| 112 | set build-shaderc=1 |
| 113 | |
| 114 | if %sync-glslang% equ 1 ( |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 115 | if not exist %GLSLANG_DIR% ( |
| 116 | call:create_glslang |
| 117 | ) |
| 118 | if %errorCode% neq 0 (goto:error) |
| 119 | call:update_glslang |
| 120 | if %errorCode% neq 0 (goto:error) |
| 121 | ) |
| 122 | |
| 123 | if %sync-spirv-tools% equ 1 ( |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 124 | if %ERRORLEVEL% neq 0 (goto:error) |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 125 | if not exist %SPIRV_TOOLS_DIR% ( |
| 126 | call:create_spirv-tools |
| 127 | ) |
| 128 | if %errorCode% neq 0 (goto:error) |
| 129 | call:update_spirv-tools |
| 130 | if %errorCode% neq 0 (goto:error) |
| 131 | ) |
| 132 | |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 133 | if %sync-spirv-headers% equ 1 ( |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 134 | if %ERRORLEVEL% neq 0 (goto:error) |
| 135 | if not exist %SPIRV_HEADERS_DIR% ( |
| 136 | call:create_spirv-headers |
| 137 | ) |
| 138 | if %errorCode% neq 0 (goto:error) |
| 139 | call:update_spirv-headers |
| 140 | if %errorCode% neq 0 (goto:error) |
| 141 | ) |
| 142 | |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 143 | if %sync-shaderc% equ 1 ( |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 144 | if not exist %SHADERC_DIR% ( |
| 145 | call:create_shaderc |
| 146 | ) |
| 147 | if %errorCode% neq 0 (goto:error) |
| 148 | call:update_shaderc |
| 149 | if %errorCode% neq 0 (goto:error) |
| 150 | ) |
| 151 | |
| 152 | if %build-shaderc% equ 1 ( |
| 153 | call:build_shaderc |
| 154 | if %errorCode% neq 0 (goto:error) |
| 155 | ) |
| 156 | |
| 157 | echo. |
| 158 | echo Exiting |
| 159 | goto:finish |
| 160 | |
| 161 | :error |
| 162 | echo. |
| 163 | echo Halting due to error |
| 164 | goto:finish |
| 165 | |
| 166 | :finish |
| 167 | if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% ) |
| 168 | endlocal |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 169 | REM This needs a fix to return error, something like exit %errorCode% |
| 170 | REM Right now it is returning 0 |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 171 | goto:eof |
| 172 | |
| 173 | |
| 174 | |
| 175 | REM // ======== Functions ======== // |
| 176 | |
| 177 | :create_glslang |
| 178 | echo. |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 179 | echo Creating local glslang repository %GLSLANG_DIR% |
Cody Northrop | 2e95469 | 2016-12-22 11:12:49 -0700 | [diff] [blame] | 180 | if not exist "%GLSLANG_DIR%\" mkdir %GLSLANG_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 181 | cd %GLSLANG_DIR% |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 182 | git clone https://github.com/KhronosGroup/glslang.git . |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 183 | git checkout %GLSLANG_REVISION% |
| 184 | if not exist %GLSLANG_DIR%\SPIRV ( |
| 185 | echo glslang source download failed! |
| 186 | set errorCode=1 |
| 187 | ) |
| 188 | goto: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% |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 196 | if not exist %GLSLANG_DIR%\SPIRV ( |
| 197 | echo glslang source update failed! |
| 198 | set errorCode=1 |
| 199 | ) |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 200 | goto:eof |
| 201 | |
| 202 | :create_spirv-tools |
| 203 | echo. |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 204 | echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR% |
Cody Northrop | 2e95469 | 2016-12-22 11:12:49 -0700 | [diff] [blame] | 205 | if not exist "%SPIRV_TOOLS_DIR%\" mkdir %SPIRV_TOOLS_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 206 | cd %SPIRV_TOOLS_DIR% |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 207 | git clone https://github.com/KhronosGroup/SPIRV-Tools.git . |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 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 | ) |
| 213 | goto: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% |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 221 | if not exist %SPIRV_TOOLS_DIR%\source ( |
| 222 | echo spirv-tools source update failed! |
| 223 | set errorCode=1 |
| 224 | ) |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 225 | goto:eof |
| 226 | |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 227 | :create_spirv-headers |
| 228 | echo. |
| 229 | echo Creating local spirv-headers repository %SPIRV_HEADERS_DIR% |
Cody Northrop | 2e95469 | 2016-12-22 11:12:49 -0700 | [diff] [blame] | 230 | if not exist "%SPIRV_HEADERS_DIR%\" mkdir %SPIRV_HEADERS_DIR% |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 231 | cd %SPIRV_HEADERS_DIR% |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 232 | git clone https://github.com/KhronosGroup/SPIRV-Headers.git . |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 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 | ) |
| 238 | goto: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 | ) |
| 250 | goto:eof |
| 251 | |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 252 | :create_shaderc |
| 253 | echo. |
Tobin Ehlis | 0d3af34 | 2016-06-10 02:35:27 -0600 | [diff] [blame] | 254 | echo Creating local shaderc repository %SHADERC_DIR% |
Cody Northrop | 2e95469 | 2016-12-22 11:12:49 -0700 | [diff] [blame] | 255 | if not exist "%SHADERC_DIR%\" mkdir %SHADERC_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 256 | cd %SHADERC_DIR% |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 257 | git clone https://github.com/google/shaderc.git . |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 258 | git checkout %SHADERC_REVISION% |
| 259 | if not exist %SHADERC_DIR%\libshaderc ( |
| 260 | echo shaderc source download failed! |
| 261 | set errorCode=1 |
| 262 | ) |
| 263 | goto: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% |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 271 | if not exist %SHADERC_DIR%\libshaderc ( |
| 272 | echo shaderc source update failed! |
| 273 | set errorCode=1 |
| 274 | ) |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 275 | goto: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 THIRD_PARTY_PATH=../.. -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 | ) |
| 289 | goto:eof |