Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Update source for glslang, spirv-tools, shaderc |
| 3 | |
| 4 | # Copyright 2016 The Android Open Source Project |
| 5 | # Copyright (C) 2015 Valve Corporation |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | |
| 19 | set -e |
| 20 | |
| 21 | ANDROIDBUILDDIR=$PWD |
Cody Northrop | 544a42e | 2016-11-03 14:44:55 -0600 | [diff] [blame] | 22 | BUILDDIR=$ANDROIDBUILDDIR |
Cody Northrop | 217d23c | 2016-05-03 15:38:05 -0600 | [diff] [blame] | 23 | BASEDIR=$BUILDDIR/external |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 24 | |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 25 | GLSLANG_REVISION=$(cat $ANDROIDBUILDDIR/glslang_revision_android) |
| 26 | SPIRV_TOOLS_REVISION=$(cat $ANDROIDBUILDDIR/spirv-tools_revision_android) |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 27 | SPIRV_HEADERS_REVISION=$(cat $ANDROIDBUILDDIR/spirv-headers_revision_android) |
Cody Northrop | 4bf55d7 | 2016-03-31 16:33:00 -0600 | [diff] [blame] | 28 | SHADERC_REVISION=$(cat $ANDROIDBUILDDIR/shaderc_revision_android) |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 29 | |
| 30 | echo "GLSLANG_REVISION=$GLSLANG_REVISION" |
| 31 | echo "SPIRV_TOOLS_REVISION=$SPIRV_TOOLS_REVISION" |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 32 | echo "SPIRV_HEADERS_REVISION=$SPIRV_HEADERS_REVISION" |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 33 | echo "SHADERC_REVISION=$SHADERC_REVISION" |
| 34 | |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 35 | GLSLANG_URL=$(cat $ANDROIDBUILDDIR/glslang_url_android) |
| 36 | SPIRV_TOOLS_URL=$(cat $ANDROIDBUILDDIR/spirv-tools_url_android) |
| 37 | SPIRV_HEADERS_URL=$(cat $ANDROIDBUILDDIR/spirv-headers_url_android) |
| 38 | SHADERC_URL=$(cat $ANDROIDBUILDDIR/shaderc_url_android) |
| 39 | |
| 40 | echo "GLSLANG_URL=$GLSLANG_URL" |
| 41 | echo "SPIRV_TOOL_URLS_=$SPIRV_TOOLS_URL" |
| 42 | echo "SPIRV_HEADERS_URL=$SPIRV_HEADERS_URL" |
| 43 | echo "SHADERC_URL=$SHADERC_URL" |
| 44 | |
Cody Northrop | 6e556a1 | 2016-11-03 14:35:08 -0600 | [diff] [blame] | 45 | if [[ $(uname) == "Linux" ]]; then |
Ciro Santilli | 0a05dd7 | 2017-03-07 08:00:31 +0000 | [diff] [blame] | 46 | cores="$(nproc || echo 4)" |
Cody Northrop | 6e556a1 | 2016-11-03 14:35:08 -0600 | [diff] [blame] | 47 | elif [[ $(uname) == "Darwin" ]]; then |
| 48 | cores=$(sysctl -n hw.ncpu) |
| 49 | fi |
| 50 | |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 51 | function create_glslang () { |
| 52 | rm -rf $BASEDIR/glslang |
| 53 | echo "Creating local glslang repository ($BASEDIR/glslang)." |
| 54 | mkdir -p $BASEDIR/glslang |
| 55 | cd $BASEDIR/glslang |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 56 | git clone $GLSLANG_URL . |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 57 | git checkout $GLSLANG_REVISION |
| 58 | } |
| 59 | |
| 60 | function update_glslang () { |
| 61 | echo "Updating $BASEDIR/glslang" |
| 62 | cd $BASEDIR/glslang |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 63 | if [[ $(git config --get remote.origin.url) != $GLSLANG_URL ]]; then |
| 64 | echo "glslang URL mismatch, recreating local repo" |
| 65 | create_glslang |
| 66 | return |
| 67 | fi |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 68 | git fetch --all |
| 69 | git checkout $GLSLANG_REVISION |
| 70 | } |
| 71 | |
| 72 | function create_spirv-tools () { |
| 73 | rm -rf $BASEDIR/spirv-tools |
| 74 | echo "Creating local spirv-tools repository ($BASEDIR/spirv-tools)." |
| 75 | mkdir -p $BASEDIR/spirv-tools |
| 76 | cd $BASEDIR/spirv-tools |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 77 | git clone $SPIRV_TOOLS_URL . |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 78 | git checkout $SPIRV_TOOLS_REVISION |
| 79 | } |
| 80 | |
| 81 | function update_spirv-tools () { |
| 82 | echo "Updating $BASEDIR/spirv-tools" |
| 83 | cd $BASEDIR/spirv-tools |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 84 | if [[ $(git config --get remote.origin.url) != $SPIRV_TOOLS_URL ]]; then |
| 85 | echo "spirv-tools URL mismatch, recreating local repo" |
| 86 | create_spirv-tools |
| 87 | return |
| 88 | fi |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 89 | git fetch --all |
| 90 | git checkout $SPIRV_TOOLS_REVISION |
| 91 | } |
| 92 | |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 93 | function create_spirv-headers () { |
| 94 | rm -rf $BASEDIR/spirv-tools/external/spirv-headers |
| 95 | echo "Creating local spirv-headers repository ($BASEDIR/spirv-tools/external/spirv-headers)." |
| 96 | mkdir -p $BASEDIR/spirv-tools/external/spirv-headers |
| 97 | cd $BASEDIR/spirv-tools/external/spirv-headers |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 98 | git clone $SPIRV_HEADERS_URL . |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 99 | git checkout $SPIRV_HEADERS_REVISION |
| 100 | } |
| 101 | |
| 102 | function update_spirv-headers () { |
| 103 | echo "Updating $BASEDIR/spirv-tools/external/spirv-headers" |
| 104 | cd $BASEDIR/spirv-tools/external/spirv-headers |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 105 | if [[ $(git config --get remote.origin.url) != $SPIRV_HEADERS_URL ]]; then |
| 106 | echo "spirv-headers URL mismatch, recreating local repo" |
| 107 | create_spirv-headers |
| 108 | return |
| 109 | fi |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 110 | git fetch --all |
| 111 | git checkout $SPIRV_HEADERS_REVISION |
| 112 | } |
| 113 | |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 114 | function create_shaderc () { |
| 115 | rm -rf $BASEDIR/shaderc |
| 116 | echo "Creating local shaderc repository ($BASEDIR/shaderc)." |
| 117 | cd $BASEDIR |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 118 | git clone $SHADERC_URL |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 119 | cd shaderc |
| 120 | git checkout $SHADERC_REVISION |
| 121 | } |
| 122 | |
| 123 | function update_shaderc () { |
| 124 | echo "Updating $BASEDIR/shaderc" |
| 125 | cd $BASEDIR/shaderc |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 126 | if [[ $(git config --get remote.origin.url) != $SHADERC_URL ]]; then |
| 127 | echo "shaderc URL mismatch, recreating local repo" |
| 128 | create_shaderc |
| 129 | return |
| 130 | fi |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 131 | git fetch --all |
| 132 | git checkout $SHADERC_REVISION |
| 133 | } |
| 134 | |
| 135 | function build_shaderc () { |
| 136 | echo "Building $BASEDIR/shaderc" |
| 137 | cd $BASEDIR/shaderc/android_test |
Cody Northrop | 6e556a1 | 2016-11-03 14:35:08 -0600 | [diff] [blame] | 138 | ndk-build THIRD_PARTY_PATH=../.. -j $cores |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | if [ ! -d "$BASEDIR/glslang" -o ! -d "$BASEDIR/glslang/.git" -o -d "$BASEDIR/glslang/.svn" ]; then |
| 142 | create_glslang |
| 143 | fi |
Cody Northrop | 7396cb0 | 2017-03-27 16:30:14 -0600 | [diff] [blame] | 144 | update_glslang |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 145 | |
| 146 | |
| 147 | if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then |
| 148 | create_spirv-tools |
| 149 | fi |
| 150 | update_spirv-tools |
| 151 | |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 152 | if [ ! -d "$BASEDIR/spirv-tools/external/spirv-headers" -o ! -d "$BASEDIR/spirv-tools/external/spirv-headers/.git" ]; then |
| 153 | create_spirv-headers |
| 154 | fi |
| 155 | update_spirv-headers |
| 156 | |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 157 | if [ ! -d "$BASEDIR/shaderc" -o ! -d "$BASEDIR/shaderc/.git" ]; then |
| 158 | create_shaderc |
| 159 | fi |
| 160 | update_shaderc |
| 161 | build_shaderc |
| 162 | |
| 163 | echo "" |
| 164 | echo "${0##*/} finished." |
| 165 | |