2 REM Update source for glslang, spirv-tools, and shaderc
5 REM Copyright 2016 The Android Open Source Project
6 REM Copyright (C) 2015 Valve Corporation
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
12 REM http://www.apache.org/licenses/LICENSE-2.0
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.
21 setlocal EnableDelayedExpansion
23 set ANDROID_BUILD_DIR=%~dp0
24 set BUILD_DIR=%ANDROID_BUILD_DIR%
25 set BASE_DIR=%BUILD_DIR%\third_party
26 set GLSLANG_DIR=%BASE_DIR%\shaderc\third_party\glslang
27 set SPIRV_TOOLS_DIR=%BASE_DIR%\shaderc\third_party\spirv-tools
28 set SPIRV_HEADERS_DIR=%BASE_DIR%\shaderc\third_party\spirv-tools\external\spirv-headers
29 set SHADERC_DIR=%BASE_DIR%\shaderc
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.
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
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
57 REM ensure where is working with below false test
59 REM if %ERRORLEVEL% equ 1 (
65 if %errorCode% neq 0 (goto:error)
67 REM Read the target versions from external file, which is shared with Linux script
69 if not exist %ANDROID_BUILD_DIR%\glslang_revision_android (
71 echo Missing glslang_revision_android file. Place it in %ANDROID_BUILD_DIR%
75 if not exist %ANDROID_BUILD_DIR%\spirv-tools_revision_android (
77 echo Missing spirv-tools_revision_android file. Place it in %ANDROID_BUILD_DIR%
82 if not exist %ANDROID_BUILD_DIR%\spirv-headers_revision_android (
84 echo Missing spirv-headers_revision_android file. Place it in %ANDROID_BUILD_DIR%
89 if not exist %ANDROID_BUILD_DIR%\shaderc_revision_android (
91 echo Missing shaderc_revision_android file. Place it in %ANDROID_BUILD_DIR%
96 set /p GLSLANG_REVISION= < glslang_revision_android
97 set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision_android
98 set /p SPIRV_HEADERS_REVISION= < spirv-headers_revision_android
99 set /p SHADERC_REVISION= < shaderc_revision_android
100 echo GLSLANG_REVISION=%GLSLANG_REVISION%
101 echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
102 echo SPIRV_HEADERS_REVISION=%SPIRV_HEADERS_REVISION%
103 echo SHADERC_REVISION=%SHADERC_REVISION%
106 echo Creating and/or updating glslang, spirv-tools, spirv-headers, shaderc in %BASE_DIR%
109 set sync-spirv-tools=1
110 set sync-spirv-headers=1
114 if %sync-shaderc% equ 1 (
115 if not exist %SHADERC_DIR% (
118 if %errorCode% neq 0 (goto:error)
120 if %errorCode% neq 0 (goto:error)
123 if %sync-glslang% equ 1 (
124 if not exist %GLSLANG_DIR% (
127 if %errorCode% neq 0 (goto:error)
129 if %errorCode% neq 0 (goto:error)
132 if %sync-spirv-tools% equ 1 (
133 if %ERRORLEVEL% neq 0 (goto:error)
134 if not exist %SPIRV_TOOLS_DIR% (
135 call:create_spirv-tools
137 if %errorCode% neq 0 (goto:error)
138 call:update_spirv-tools
139 if %errorCode% neq 0 (goto:error)
142 if %sync-spirv-headers% equ 1 (
143 if %ERRORLEVEL% neq 0 (goto:error)
144 if not exist %SPIRV_HEADERS_DIR% (
145 call:create_spirv-headers
147 if %errorCode% neq 0 (goto:error)
148 call:update_spirv-headers
149 if %errorCode% neq 0 (goto:error)
152 if %build-shaderc% equ 1 (
154 if %errorCode% neq 0 (goto:error)
163 echo Halting due to error
167 if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
169 REM This needs a fix to return error, something like exit %errorCode%
170 REM Right now it is returning 0
175 REM // ======== Functions ======== //
179 echo Creating local glslang repository %GLSLANG_DIR%
180 if not exist "%GLSLANG_DIR%\" mkdir %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!
192 echo Updating %GLSLANG_DIR%
195 git checkout %GLSLANG_REVISION%
196 if not exist %GLSLANG_DIR%\SPIRV (
197 echo glslang source update failed!
204 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%
205 if not exist "%SPIRV_TOOLS_DIR%\" mkdir %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!
217 echo Updating %SPIRV_TOOLS_DIR%
220 git checkout %SPIRV_TOOLS_REVISION%
221 if not exist %SPIRV_TOOLS_DIR%\source (
222 echo spirv-tools source update failed!
227 :create_spirv-headers
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!
240 :update_spirv-headers
242 echo Updating %SPIRV_HEADERS_DIR%
243 cd %SPIRV_HEADERS_DIR%
245 git checkout %SPIRV_HEADERS_REVISION%
246 if not exist %SPIRV_HEADERS_DIR%\include (
247 echo spirv-headers source update failed!
254 echo Creating local shaderc repository %SHADERC_DIR%
255 if not exist "%SHADERC_DIR%\" mkdir %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!
267 echo Updating %SHADERC_DIR%
270 git checkout %SHADERC_REVISION%
271 if not exist %SHADERC_DIR%\libshaderc (
272 echo shaderc source update failed!
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=../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 (
286 echo shaderc build failed!