blob: 08d96308c5a7e8b8ff49c8adb159fcc2e0167d58 [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
24set BUILD_DIR=%ANDROID_BUILD_DIR%..
25set BASE_DIR=%BUILD_DIR%\..
26set GLSLANG_DIR=%BASE_DIR%\glslang
27set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools
28set SHADERC_DIR=%BASE_DIR%\shaderc
29
30for %%X in (where.exe) do (set FOUND=%%~$PATH:X)
31if 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
38where /q git.exe
39if %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
47where /q ndk-build.cmd
48if %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
56REM ensure where is working with below false test
57REM where /q foo
58REM if %ERRORLEVEL% equ 1 (
59REM echo foo
60REM )
61
62:main
63
64if %errorCode% neq 0 (goto:error)
65
66REM Read the target versions from external file, which is shared with Linux script
67
Cody Northrop4bf55d72016-03-31 16:33:00 -060068if not exist %ANDROID_BUILD_DIR%\glslang_revision_android (
Cody Northropb3106db2016-03-29 10:06:49 -060069 echo.
Cody Northrop4bf55d72016-03-31 16:33:00 -060070 echo Missing glslang_revision_android file. Place it in %ANDROID_BUILD_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -060071 goto:error
72)
73
Cody Northrop4bf55d72016-03-31 16:33:00 -060074if not exist %ANDROID_BUILD_DIR%\spirv-tools_revision_android (
Cody Northropb3106db2016-03-29 10:06:49 -060075 echo.
Cody Northrop4bf55d72016-03-31 16:33:00 -060076 echo Missing spirv-tools_revision_android file. Place it in %ANDROID_BUILD_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -060077 set errorCode=1
78 goto:error
79)
80
Cody Northrop4bf55d72016-03-31 16:33:00 -060081if not exist %ANDROID_BUILD_DIR%\shaderc_revision_android (
Cody Northropb3106db2016-03-29 10:06:49 -060082 echo.
Cody Northrop4bf55d72016-03-31 16:33:00 -060083 echo Missing shaderc_revision_android file. Place it in %ANDROID_BUILD_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -060084 set errorCode=1
85 goto:error
86)
87
Cody Northrop4bf55d72016-03-31 16:33:00 -060088set /p GLSLANG_REVISION= < glslang_revision_android
89set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision_android
90set /p SHADERC_REVISION= < shaderc_revision_android
Cody Northropb3106db2016-03-29 10:06:49 -060091echo GLSLANG_REVISION=%GLSLANG_REVISION%
92echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
93echo SHADERC_REVISION=%SHADERC_REVISION%
94
95
96echo Creating and/or updating glslang, spirv-tools, shaderc in %BASE_DIR%
97
98set sync-glslang=1
99set sync-spirv-tools=1
100set sync-shaderc=1
101set build-shaderc=1
102
103if %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
115if %sync-spirv-tools% equ 1 (
116 if exist %SPIRV_TOOLS_DIR% (
117 rd /S /Q %SPIRV_TOOLS_DIR%
118 )
Cody Northrop2775d792016-04-14 11:18:30 -0600119 if %ERRORLEVEL% neq 0 (goto:error)
Cody Northropb3106db2016-03-29 10:06:49 -0600120 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
128if %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
140if %build-shaderc% equ 1 (
141 call:build_shaderc
142 if %errorCode% neq 0 (goto:error)
143)
144
145echo.
146echo Exiting
147goto:finish
148
149:error
150echo.
151echo Halting due to error
152goto:finish
153
154:finish
155if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
156endlocal
157goto:eof
158
159
160
161REM // ======== Functions ======== //
162
163:create_glslang
164 echo.
Cody Northrop2775d792016-04-14 11:18:30 -0600165 echo Creating local glslang repository %GLSLANG_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -0600166 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 )
174goto: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 Northrop2775d792016-04-14 11:18:30 -0600182 if not exist %GLSLANG_DIR%\SPIRV (
183 echo glslang source update failed!
184 set errorCode=1
185 )
Cody Northropb3106db2016-03-29 10:06:49 -0600186goto:eof
187
188:create_spirv-tools
189 echo.
Cody Northrop2775d792016-04-14 11:18:30 -0600190 echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%
Cody Northropb3106db2016-03-29 10:06:49 -0600191 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 )
199goto: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 Northrop2775d792016-04-14 11:18:30 -0600207 if not exist %SPIRV_TOOLS_DIR%\source (
208 echo spirv-tools source update failed!
209 set errorCode=1
210 )
Cody Northropb3106db2016-03-29 10:06:49 -0600211goto: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 )
224goto: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 Northrop2775d792016-04-14 11:18:30 -0600232 if not exist %SHADERC_DIR%\libshaderc (
233 echo shaderc source update failed!
234 set errorCode=1
235 )
Cody Northropb3106db2016-03-29 10:06:49 -0600236goto: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 )
250goto:eof