aboutsummaryrefslogtreecommitdiff
path: root/build-android/update_external_sources_android.bat
blob: 5c6f2554634bdd4a362728e1833abffe7b153344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
@echo off
REM Update source for vulkan-headers

REM
REM Copyright 2016 The Android Open Source Project
REM Copyright (C) 2015 Valve Corporation
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
REM      http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.
REM

setlocal EnableDelayedExpansion
set errorCode=0
set ANDROID_BUILD_DIR=%~dp0
set BUILD_DIR=%ANDROID_BUILD_DIR%
set BASE_DIR=%BUILD_DIR%\third_party
set VULKAN_HEADERS_DIR=%BASE_DIR%\Vulkan-Headers

for %%X in (where.exe) do (set FOUND=%%~$PATH:X)
if not defined FOUND (
   echo Dependency check failed:
   echo   where.exe not found
   echo   This script requires Windows Vista or later, which includes where.exe.
   set errorCode=1
)

where /q git.exe
if %ERRORLEVEL% equ 1 (
   echo Dependency check failed:
   echo   git.exe not found
   echo   Git for Windows can be downloaded here:  https://git-scm.com/download/win
   echo   Install and ensure git.exe makes it into your PATH
   set errorCode=1
)

where /q ndk-build.cmd
if %ERRORLEVEL% equ 1 (
   echo Dependency check failed:
   echo   ndk-build.cmd not found
   echo   Android NDK can be downloaded here:  http://developer.android.com/ndk/guides/setup.html
   echo   Install and ensure ndk-build.cmd makes it into your PATH
   set errorCode=1
)

REM ensure where is working with below false test
REM where /q foo
REM if %ERRORLEVEL% equ 1 (
REM echo foo
REM )

:main

if %errorCode% neq 0 (goto:error)

REM Read the target versions from external file, which is shared with Linux script

if not exist %ANDROID_BUILD_DIR%\vulkan-headers_revision_android (
   echo.
   echo Missing vulkan-headers_revision_android file. Place it in %ANDROID_BUILD_DIR%
   set errorCode=1
   goto:error
)

set /p VULKAN_HEADERS_REVISION= < vulkan-headers_revision_android
echo VULKAN_HEADERS_REVISION=%VULKAN_HEADERS_REVISION%


echo Creating vulkan-headers in %BASE_DIR%

set sync-vulkan-headers=1

if %sync-vulkan-headers% equ 1 (
   if %ERRORLEVEL% neq 0 (goto:error)
   if not exist %VULKAN_HEADERS_DIR% (
      call:create_vulkan-headers
   )
   if %errorCode% neq 0 (goto:error)
   call:update_vulkan-headers
   if %errorCode% neq 0 (goto:error)
)

echo.
echo Exiting
goto:finish

:error
echo.
echo Halting due to error
goto:finish

:finish
if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
endlocal
REM This needs a fix to return error, something like exit %errorCode%
REM Right now it is returning 0
goto:eof



REM // ======== Functions ======== //

:create_vulkan-headers
   echo.
   echo Creating local vulkan-headers repository %VULKAN_HEADERS_DIR%
   if not exist "%VULKAN_HEADERS_DIR%\" mkdir %VULKAN_HEADERS_DIR%
   cd %VULKAN_HEADERS_DIR%
   git clone https://github.com/KhronosGroup/Vulkan-Headers.git .
   git checkout %VULKAN_HEADERS_REVISION%
   if not exist %VULKAN_HEADERS_DIR%\registry (
      echo vulkan-headers source download failed!
      set errorCode=1
   )
goto:eof

:update_vulkan-headers
   echo.
   echo Updating %VULKAN_HEADERS_DIR%
   cd %VULKAN_HEADERS_DIR%
   git fetch --all
   git checkout %VULKAN_HEADERS_REVISION%
   if not exist %VULKAN_HEADERS_DIR%\registry (
      echo vulkan-headers source update failed!
      set errorCode=1
   )
goto:eof