blob: 36deaf8c0e1802766682cd2b61e9b0317510a1b2 [file] [log] [blame]
Cody Northropb3106db2016-03-29 10:06:49 -06001@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
Cody Northrop544a42e2016-11-03 14:44:55 -060024set BUILD_DIR=%ANDROID_BUILD_DIR%
Cody Northrop217d23c2016-05-03 15:38:05 -060025set BASE_DIR=%BUILD_DIR%\external
Cody Northropb3106db2016-03-29 10:06:49 -060026set GLSLANG_DIR=%BASE_DIR%\glslang
27set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools
Cody Northrop83ff93f2016-08-01 10:27:25 -060028set SPIRV_HEADERS_DIR=%BASE_DIR%\spirv-tools\external\spirv-headers
Cody Northropb3106db2016-03-29 10:06:49 -060029set 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
Cody Northrop4bf55d72016-03-31 16:33:00 -060069if not exist %ANDROID_BUILD_DIR%\glslang_revision_android (
Cody Northropb3106db2016-03-29 10:06:49 -060070 echo.
Cody Northrop4bf55d72016-03-31 16:33:00 -060071 echo Missing glslang_revision_android file. Place it in %ANDROID_BUILD_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -060072 goto:error
73)
74
Cody Northrop4bf55d72016-03-31 16:33:00 -060075if not exist %ANDROID_BUILD_DIR%\spirv-tools_revision_android (
Cody Northropb3106db2016-03-29 10:06:49 -060076 echo.
Cody Northrop4bf55d72016-03-31 16:33:00 -060077 echo Missing spirv-tools_revision_android file. Place it in %ANDROID_BUILD_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -060078 set errorCode=1
79 goto:error
80)
81
Cody Northrop83ff93f2016-08-01 10:27:25 -060082if 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 Northrop4bf55d72016-03-31 16:33:00 -060089if not exist %ANDROID_BUILD_DIR%\shaderc_revision_android (
Cody Northropb3106db2016-03-29 10:06:49 -060090 echo.
Cody Northrop4bf55d72016-03-31 16:33:00 -060091 echo Missing shaderc_revision_android file. Place it in %ANDROID_BUILD_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -060092 set errorCode=1
93 goto:error
94)
95
Cody Northrop4bf55d72016-03-31 16:33:00 -060096set /p GLSLANG_REVISION= < glslang_revision_android
97set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision_android
Cody Northrop83ff93f2016-08-01 10:27:25 -060098set /p SPIRV_HEADERS_REVISION= < spirv-headers_revision_android
Cody Northrop4bf55d72016-03-31 16:33:00 -060099set /p SHADERC_REVISION= < shaderc_revision_android
Cody Northropb3106db2016-03-29 10:06:49 -0600100echo GLSLANG_REVISION=%GLSLANG_REVISION%
101echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
Cody Northrop83ff93f2016-08-01 10:27:25 -0600102echo SPIRV_HEADERS_REVISION=%SPIRV_HEADERS_REVISION%
Cody Northropb3106db2016-03-29 10:06:49 -0600103echo SHADERC_REVISION=%SHADERC_REVISION%
104
105
Cody Northrop83ff93f2016-08-01 10:27:25 -0600106echo Creating and/or updating glslang, spirv-tools, spirv-headers, shaderc in %BASE_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -0600107
108set sync-glslang=1
109set sync-spirv-tools=1
Cody Northrop83ff93f2016-08-01 10:27:25 -0600110set sync-spirv-headers=1
Cody Northropb3106db2016-03-29 10:06:49 -0600111set sync-shaderc=1
112set build-shaderc=1
113
114if %sync-glslang% equ 1 (
Cody Northropb3106db2016-03-29 10:06:49 -0600115 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
123if %sync-spirv-tools% equ 1 (
Cody Northrop2775d792016-04-14 11:18:30 -0600124 if %ERRORLEVEL% neq 0 (goto:error)
Cody Northropb3106db2016-03-29 10:06:49 -0600125 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 Northrop83ff93f2016-08-01 10:27:25 -0600133if %sync-spirv-headers% equ 1 (
Cody Northrop83ff93f2016-08-01 10:27:25 -0600134 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 Northropb3106db2016-03-29 10:06:49 -0600143if %sync-shaderc% equ 1 (
Cody Northropb3106db2016-03-29 10:06:49 -0600144 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
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
Cody Northrop83ff93f2016-08-01 10:27:25 -0600169REM This needs a fix to return error, something like exit %errorCode%
170REM Right now it is returning 0
Cody Northropb3106db2016-03-29 10:06:49 -0600171goto:eof
172
173
174
175REM // ======== Functions ======== //
176
177:create_glslang
178 echo.
Cody Northrop2775d792016-04-14 11:18:30 -0600179 echo Creating local glslang repository %GLSLANG_DIR%
Cody Northrop2e954692016-12-22 11:12:49 -0700180 if not exist "%GLSLANG_DIR%\" mkdir %GLSLANG_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -0600181 cd %GLSLANG_DIR%
Cody Northrop7396cb02017-03-27 16:30:14 -0600182 git clone https://github.com/KhronosGroup/glslang.git .
Cody Northropb3106db2016-03-29 10:06:49 -0600183 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%
Cody Northrop2775d792016-04-14 11:18:30 -0600196 if not exist %GLSLANG_DIR%\SPIRV (
197 echo glslang source update failed!
198 set errorCode=1
199 )
Cody Northropb3106db2016-03-29 10:06:49 -0600200goto:eof
201
202:create_spirv-tools
203 echo.
Cody Northrop2775d792016-04-14 11:18:30 -0600204 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%
Cody Northrop2e954692016-12-22 11:12:49 -0700205 if not exist "%SPIRV_TOOLS_DIR%\" mkdir %SPIRV_TOOLS_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -0600206 cd %SPIRV_TOOLS_DIR%
Cody Northrop7396cb02017-03-27 16:30:14 -0600207 git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
Cody Northropb3106db2016-03-29 10:06:49 -0600208 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%
Cody Northrop2775d792016-04-14 11:18:30 -0600221 if not exist %SPIRV_TOOLS_DIR%\source (
222 echo spirv-tools source update failed!
223 set errorCode=1
224 )
Cody Northropb3106db2016-03-29 10:06:49 -0600225goto:eof
226
Cody Northrop83ff93f2016-08-01 10:27:25 -0600227:create_spirv-headers
228 echo.
229 echo Creating local spirv-headers repository %SPIRV_HEADERS_DIR%
Cody Northrop2e954692016-12-22 11:12:49 -0700230 if not exist "%SPIRV_HEADERS_DIR%\" mkdir %SPIRV_HEADERS_DIR%
Cody Northrop83ff93f2016-08-01 10:27:25 -0600231 cd %SPIRV_HEADERS_DIR%
Cody Northrop7396cb02017-03-27 16:30:14 -0600232 git clone https://github.com/KhronosGroup/SPIRV-Headers.git .
Cody Northrop83ff93f2016-08-01 10:27:25 -0600233 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
Cody Northropb3106db2016-03-29 10:06:49 -0600252:create_shaderc
253 echo.
Tobin Ehlis0d3af342016-06-10 02:35:27 -0600254 echo Creating local shaderc repository %SHADERC_DIR%
Cody Northrop2e954692016-12-22 11:12:49 -0700255 if not exist "%SHADERC_DIR%\" mkdir %SHADERC_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -0600256 cd %SHADERC_DIR%
Cody Northrop7396cb02017-03-27 16:30:14 -0600257 git clone https://github.com/google/shaderc.git .
Cody Northropb3106db2016-03-29 10:06:49 -0600258 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%
Cody Northrop2775d792016-04-14 11:18:30 -0600271 if not exist %SHADERC_DIR%\libshaderc (
272 echo shaderc source update failed!
273 set errorCode=1
274 )
Cody Northropb3106db2016-03-29 10:06:49 -0600275goto: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 )
289goto:eof