1@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 Copyright 2018 LunarG, Inc.
8REM
9REM Licensed under the Apache License, Version 2.0 (the "License");
10REM you may not use this file except in compliance with the License.
11REM You may obtain a copy of the License at
12REM
13REM      http://www.apache.org/licenses/LICENSE-2.0
14REM
15REM Unless required by applicable law or agreed to in writing, software
16REM distributed under the License is distributed on an "AS IS" BASIS,
17REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18REM See the License for the specific language governing permissions and
19REM limitations under the License.
20REM
21
22setlocal EnableDelayedExpansion
23set errorCode=0
24set ANDROID_BUILD_DIR=%~dp0
25set BUILD_DIR=%ANDROID_BUILD_DIR%
26set BASE_DIR=%BUILD_DIR%\third_party
27set SHADERC_DIR=%BASE_DIR%\shaderc
28
29for %%X in (where.exe) do (set FOUND=%%~$PATH:X)
30if not defined FOUND (
31   echo Dependency check failed:
32   echo   where.exe not found
33   echo   This script requires Windows Vista or later, which includes where.exe.
34   set errorCode=1
35)
36
37where /q git.exe
38if %ERRORLEVEL% equ 1 (
39   echo Dependency check failed:
40   echo   git.exe not found
41   echo   Git for Windows can be downloaded here:  https://git-scm.com/download/win
42   echo   Install and ensure git.exe makes it into your PATH
43   set errorCode=1
44)
45
46where /q ndk-build.cmd
47if %ERRORLEVEL% equ 1 (
48   echo Dependency check failed:
49   echo   ndk-build.cmd not found
50   echo   Android NDK can be downloaded here:  http://developer.android.com/ndk/guides/setup.html
51   echo   Install and ensure ndk-build.cmd makes it into your PATH
52   set errorCode=1
53)
54
55:main
56
57if %errorCode% neq 0 (goto:error)
58
59echo Creating and/or updating glslang, spirv-tools, spirv-headers, shaderc, vulkan-headers, vulkan-tools in %BASE_DIR%
60
61set build-shaderc=1
62
63REM Pull down or update external dependencies
64echo Update external dependencies based on the %ANDROID_BUILD_DIR%/known_good.json file
65py -3 ../scripts/update_deps.py --no-build --dir %BASE_DIR% --known_good_dir %BUILD_DIR%
66
67
68if %build-shaderc% equ 1 (
69   call:build_shaderc
70   if %errorCode% neq 0 (goto:error)
71)
72
73echo.
74echo Exiting
75goto:finish
76
77:error
78echo.
79echo Halting due to error
80goto:finish
81
82:finish
83if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
84endlocal
85REM This needs a fix to return error, something like exit %errorCode%
86REM Right now it is returning 0
87goto:eof
88
89
90
91REM // ======== Functions ======== //
92
93:build_shaderc
94   echo.
95   echo Building %SHADERC_DIR%
96   cd %SHADERC_DIR%\android_test
97   echo Building shaderc with Android NDK
98   call ndk-build NDK_APPLICATION_MK=../../../jni/shaderc/Application.mk THIRD_PARTY_PATH=../third_party -j 4
99   REM Check for existence of one lib, even though we should check for all results
100   if not exist %SHADERC_DIR%\android_test\obj\local\x86\libshaderc.a (
101      echo.
102      echo shaderc build failed!
103      set errorCode=1
104   )
105goto:eof
106