aboutsummaryrefslogtreecommitdiff
path: root/build-android/update_external_sources_android.sh
blob: d86682d93f8647cdf560c778d06f74f82917a216 (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
#!/bin/bash
# Update source for vulkan-headers

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

set -e

sync_vulkan_headers=1

ANDROIDBUILDDIR=$PWD
BUILDDIR=$ANDROIDBUILDDIR
BASEDIR=$BUILDDIR/third_party

VULKAN_HEADERS_REVISION=$(cat $ANDROIDBUILDDIR/vulkan-headers_revision_android)

echo "VULKAN_HEADERS_REVISION=$VULKAN_HEADERS_REVISION"

VULKAN_HEADERS_URL=$(cat $ANDROIDBUILDDIR/vulkan-headers_url_android)

if [[ $(uname) == "Linux" ]]; then
    cores="$(nproc || echo 4)"
elif [[ $(uname) == "Darwin" ]]; then
    cores=$(sysctl -n hw.ncpu)
fi

#
# Parse parameters
#

function printUsage {
   echo "Supported parameters are:"
   echo "    --abi <abi> (optional)"
   echo "    --no-build (optional)"
   echo
   echo "i.e. ${0##*/} --abi arm64-v8a \\"
   exit 1
}

while [[ $# -gt 0 ]]
do
    case $1 in
        --abi)
            abi="$2"
            shift 2
            ;;
        --no-build)
            nobuild=1
            shift 1
            ;;
        *)
            # unknown option
            echo Unknown option: $1
            echo
            printUsage
            exit 1
            ;;
    esac
done

echo abi=$abi
if [[ -z $abi ]]
then
    echo No abi provided, so building for all supported abis.
fi

echo no-build=$nobuild
if [[ $nobuild ]]
then
    echo Skipping build.
fi

function create_vulkan-headers () {
   rm -rf $BASEDIR/Vulkan-Headers
   echo "Creating local Vulkan-Headers repository ($BASEDIR/Vulkan-Headers)."
   mkdir -p $BASEDIR/Vulkan-Headers
   cd $BASEDIR/Vulkan-Headers
   git clone $VULKAN_HEADERS_URL .
   git checkout $VULKAN_HEADERS_REVISION
}

function update_vulkan-headers () {
   echo "Updating $BASEDIR/Vulkan-Headers"
   cd $BASEDIR/Vulkan-Headers
   if [[ $(git config --get remote.origin.url) != $VULKAN_HEADERS_URL ]]; then
      echo "Vulkan-Headers URL mismatch, recreating local repo"
      create_vulkan-headers
      return
   fi
   git fetch --all
   git checkout $VULKAN_HEADERS_REVISION
}

if [ $sync_vulkan_headers -eq 1 ]; then
    if [ ! -d "$BASEDIR/Vulkan-Headers" -o ! -d "$BASEDIR/Vulkan-Headers/.git" ]; then
    create_vulkan-headers
    fi
    update_vulkan-headers
fi

echo ""
echo "${0##*/} finished."