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 |
| 24 | set BUILD_DIR=%ANDROID_BUILD_DIR%.. |
| 25 | set BASE_DIR=%BUILD_DIR%\.. |
| 26 | set GLSLANG_DIR=%BASE_DIR%\glslang |
| 27 | set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools |
| 28 | set SHADERC_DIR=%BASE_DIR%\shaderc |
| 29 | |
| 30 | for %%X in (where.exe) do (set FOUND=%%~$PATH:X) |
| 31 | if not defined FOUND ( |
| 32 | echo Dependency check failed: |
| 33 | echo where.exe not found |
| 34 | echo This script requires Windows Vista or later, which includes where.exe. |
| 35 | set errorCode=1 |
| 36 | ) |
| 37 | |
| 38 | where /q git.exe |
| 39 | if %ERRORLEVEL% equ 1 ( |
| 40 | echo Dependency check failed: |
| 41 | echo git.exe not found |
| 42 | echo Git for Windows can be downloaded here: https://git-scm.com/download/win |
| 43 | echo Install and ensure git.exe makes it into your PATH |
| 44 | set errorCode=1 |
| 45 | ) |
| 46 | |
| 47 | where /q ndk-build.cmd |
| 48 | if %ERRORLEVEL% equ 1 ( |
| 49 | echo Dependency check failed: |
| 50 | echo ndk-build.cmd not found |
| 51 | echo Android NDK can be downloaded here: http://developer.android.com/ndk/guides/setup.html |
| 52 | echo Install and ensure ndk-build.cmd makes it into your PATH |
| 53 | set errorCode=1 |
| 54 | ) |
| 55 | |
| 56 | REM ensure where is working with below false test |
| 57 | REM where /q foo |
| 58 | REM if %ERRORLEVEL% equ 1 ( |
| 59 | REM echo foo |
| 60 | REM ) |
| 61 | |
| 62 | :main |
| 63 | |
| 64 | if %errorCode% neq 0 (goto:error) |
| 65 | |
| 66 | REM Read the target versions from external file, which is shared with Linux script |
| 67 | |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 68 | if not exist %ANDROID_BUILD_DIR%\glslang_revision_android ( |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 69 | echo. |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 70 | echo Missing glslang_revision_android file. Place it in %ANDROID_BUILD_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 71 | goto:error |
| 72 | ) |
| 73 | |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 74 | if not exist %ANDROID_BUILD_DIR%\spirv-tools_revision_android ( |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 75 | echo. |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 76 | 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] | 77 | set errorCode=1 |
| 78 | goto:error |
| 79 | ) |
| 80 | |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 81 | if not exist %ANDROID_BUILD_DIR%\shaderc_revision_android ( |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 82 | echo. |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 83 | echo Missing shaderc_revision_android file. Place it in %ANDROID_BUILD_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 84 | set errorCode=1 |
| 85 | goto:error |
| 86 | ) |
| 87 | |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 88 | set /p GLSLANG_REVISION= < glslang_revision_android |
| 89 | set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision_android |
| 90 | set /p SHADERC_REVISION= < shaderc_revision_android |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 91 | echo GLSLANG_REVISION=%GLSLANG_REVISION% |
| 92 | echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION% |
| 93 | echo SHADERC_REVISION=%SHADERC_REVISION% |
| 94 | |
| 95 | |
| 96 | echo Creating and/or updating glslang, spirv-tools, shaderc in %BASE_DIR% |
| 97 | |
| 98 | set sync-glslang=1 |
| 99 | set sync-spirv-tools=1 |
| 100 | set sync-shaderc=1 |
| 101 | set build-shaderc=1 |
| 102 | |
| 103 | if %sync-glslang% equ 1 ( |
| 104 | if exist %GLSLANG_DIR% ( |
| 105 | rd /S /Q %GLSLANG_DIR% |
| 106 | ) |
| 107 | if not exist %GLSLANG_DIR% ( |
| 108 | call:create_glslang |
| 109 | ) |
| 110 | if %errorCode% neq 0 (goto:error) |
| 111 | call:update_glslang |
| 112 | if %errorCode% neq 0 (goto:error) |
| 113 | ) |
| 114 | |
| 115 | if %sync-spirv-tools% equ 1 ( |
| 116 | if exist %SPIRV_TOOLS_DIR% ( |
| 117 | rd /S /Q %SPIRV_TOOLS_DIR% |
| 118 | ) |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 119 | if %ERRORLEVEL% neq 0 (goto:error) |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 120 | if not exist %SPIRV_TOOLS_DIR% ( |
| 121 | call:create_spirv-tools |
| 122 | ) |
| 123 | if %errorCode% neq 0 (goto:error) |
| 124 | call:update_spirv-tools |
| 125 | if %errorCode% neq 0 (goto:error) |
| 126 | ) |
| 127 | |
| 128 | if %sync-shaderc% equ 1 ( |
| 129 | if exist %SHADERC_DIR% ( |
| 130 | rd /S /Q %SHADERC_DIR% |
| 131 | ) |
| 132 | if not exist %SHADERC_DIR% ( |
| 133 | call:create_shaderc |
| 134 | ) |
| 135 | if %errorCode% neq 0 (goto:error) |
| 136 | call:update_shaderc |
| 137 | if %errorCode% neq 0 (goto:error) |
| 138 | ) |
| 139 | |
| 140 | if %build-shaderc% equ 1 ( |
| 141 | call:build_shaderc |
| 142 | if %errorCode% neq 0 (goto:error) |
| 143 | ) |
| 144 | |
| 145 | echo. |
| 146 | echo Exiting |
| 147 | goto:finish |
| 148 | |
| 149 | :error |
| 150 | echo. |
| 151 | echo Halting due to error |
| 152 | goto:finish |
| 153 | |
| 154 | :finish |
| 155 | if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% ) |
| 156 | endlocal |
| 157 | goto:eof |
| 158 | |
| 159 | |
| 160 | |
| 161 | REM // ======== Functions ======== // |
| 162 | |
| 163 | :create_glslang |
| 164 | echo. |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 165 | echo Creating local glslang repository %GLSLANG_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 166 | mkdir %GLSLANG_DIR% |
| 167 | cd %GLSLANG_DIR% |
| 168 | git clone https://github.com/KhronosGroup/glslang.git . |
| 169 | git checkout %GLSLANG_REVISION% |
| 170 | if not exist %GLSLANG_DIR%\SPIRV ( |
| 171 | echo glslang source download failed! |
| 172 | set errorCode=1 |
| 173 | ) |
| 174 | goto:eof |
| 175 | |
| 176 | :update_glslang |
| 177 | echo. |
| 178 | echo Updating %GLSLANG_DIR% |
| 179 | cd %GLSLANG_DIR% |
| 180 | git fetch --all |
| 181 | git checkout %GLSLANG_REVISION% |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 182 | if not exist %GLSLANG_DIR%\SPIRV ( |
| 183 | echo glslang source update failed! |
| 184 | set errorCode=1 |
| 185 | ) |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 186 | goto:eof |
| 187 | |
| 188 | :create_spirv-tools |
| 189 | echo. |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 190 | echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR% |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 191 | mkdir %SPIRV_TOOLS_DIR% |
| 192 | cd %SPIRV_TOOLS_DIR% |
| 193 | git clone https://github.com/KhronosGroup/SPIRV-Tools.git . |
| 194 | git checkout %SPIRV_TOOLS_REVISION% |
| 195 | if not exist %SPIRV_TOOLS_DIR%\source ( |
| 196 | echo spirv-tools source download failed! |
| 197 | set errorCode=1 |
| 198 | ) |
| 199 | goto:eof |
| 200 | |
| 201 | :update_spirv-tools |
| 202 | echo. |
| 203 | echo Updating %SPIRV_TOOLS_DIR% |
| 204 | cd %SPIRV_TOOLS_DIR% |
| 205 | git fetch --all |
| 206 | git checkout %SPIRV_TOOLS_REVISION% |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 207 | if not exist %SPIRV_TOOLS_DIR%\source ( |
| 208 | echo spirv-tools source update failed! |
| 209 | set errorCode=1 |
| 210 | ) |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 211 | goto:eof |
| 212 | |
| 213 | :create_shaderc |
| 214 | echo. |
| 215 | echo Creating local shaderc repository %SHADERC_DIR%) |
| 216 | mkdir %SHADERC_DIR% |
| 217 | cd %SHADERC_DIR% |
| 218 | git clone git@github.com:google/shaderc.git . |
| 219 | git checkout %SHADERC_REVISION% |
| 220 | if not exist %SHADERC_DIR%\libshaderc ( |
| 221 | echo shaderc source download failed! |
| 222 | set errorCode=1 |
| 223 | ) |
| 224 | goto:eof |
| 225 | |
| 226 | :update_shaderc |
| 227 | echo. |
| 228 | echo Updating %SHADERC_DIR% |
| 229 | cd %SHADERC_DIR% |
| 230 | git fetch --all |
| 231 | git checkout %SHADERC_REVISION% |
Cody Northrop | 2775d79 | 2016-04-14 11:18:30 -0600 | [diff] [blame] | 232 | if not exist %SHADERC_DIR%\libshaderc ( |
| 233 | echo shaderc source update failed! |
| 234 | set errorCode=1 |
| 235 | ) |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 236 | goto:eof |
| 237 | |
| 238 | :build_shaderc |
| 239 | echo. |
| 240 | echo Building %SHADERC_DIR% |
| 241 | cd %SHADERC_DIR%\android_test |
| 242 | echo Building shaderc with Android NDK |
| 243 | call ndk-build THIRD_PARTY_PATH=../.. -j 4 |
| 244 | REM Check for existence of one lib, even though we should check for all results |
| 245 | if not exist %SHADERC_DIR%\android_test\obj\local\x86\libshaderc.a ( |
| 246 | echo. |
| 247 | echo shaderc build failed! |
| 248 | set errorCode=1 |
| 249 | ) |
| 250 | goto:eof |