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" |
| 32 | echo "SHADERC_REVISION=$SHADERC_REVISION" |
| 33 | |
Cody Northrop | 6e556a1 | 2016-11-03 14:35:08 -0600 | [diff] [blame] | 34 | if [[ $(uname) == "Linux" ]]; then |
| 35 | cores=$(ncpus) |
| 36 | elif [[ $(uname) == "Darwin" ]]; then |
| 37 | cores=$(sysctl -n hw.ncpu) |
| 38 | fi |
| 39 | |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 40 | function create_glslang () { |
| 41 | rm -rf $BASEDIR/glslang |
| 42 | echo "Creating local glslang repository ($BASEDIR/glslang)." |
| 43 | mkdir -p $BASEDIR/glslang |
| 44 | cd $BASEDIR/glslang |
Cody Northrop | bc71ca8 | 2016-11-03 14:34:17 -0600 | [diff] [blame] | 45 | git clone https://android.googlesource.com/platform/external/shaderc/glslang . |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 46 | git checkout $GLSLANG_REVISION |
| 47 | } |
| 48 | |
| 49 | function update_glslang () { |
| 50 | echo "Updating $BASEDIR/glslang" |
| 51 | cd $BASEDIR/glslang |
| 52 | git fetch --all |
| 53 | git checkout $GLSLANG_REVISION |
| 54 | } |
| 55 | |
| 56 | function create_spirv-tools () { |
| 57 | rm -rf $BASEDIR/spirv-tools |
| 58 | echo "Creating local spirv-tools repository ($BASEDIR/spirv-tools)." |
| 59 | mkdir -p $BASEDIR/spirv-tools |
| 60 | cd $BASEDIR/spirv-tools |
Cody Northrop | bc71ca8 | 2016-11-03 14:34:17 -0600 | [diff] [blame] | 61 | git clone https://android.googlesource.com/platform/external/shaderc/spirv-tools . |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 62 | git checkout $SPIRV_TOOLS_REVISION |
| 63 | } |
| 64 | |
| 65 | function update_spirv-tools () { |
| 66 | echo "Updating $BASEDIR/spirv-tools" |
| 67 | cd $BASEDIR/spirv-tools |
| 68 | git fetch --all |
| 69 | git checkout $SPIRV_TOOLS_REVISION |
| 70 | } |
| 71 | |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 72 | function create_spirv-headers () { |
| 73 | rm -rf $BASEDIR/spirv-tools/external/spirv-headers |
| 74 | echo "Creating local spirv-headers repository ($BASEDIR/spirv-tools/external/spirv-headers)." |
| 75 | mkdir -p $BASEDIR/spirv-tools/external/spirv-headers |
| 76 | cd $BASEDIR/spirv-tools/external/spirv-headers |
Cody Northrop | bc71ca8 | 2016-11-03 14:34:17 -0600 | [diff] [blame] | 77 | git clone https://android.googlesource.com/platform/external/shaderc/spirv-headers . |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 78 | git checkout $SPIRV_HEADERS_REVISION |
| 79 | } |
| 80 | |
| 81 | function update_spirv-headers () { |
| 82 | echo "Updating $BASEDIR/spirv-tools/external/spirv-headers" |
| 83 | cd $BASEDIR/spirv-tools/external/spirv-headers |
| 84 | git fetch --all |
| 85 | git checkout $SPIRV_HEADERS_REVISION |
| 86 | } |
| 87 | |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 88 | function create_shaderc () { |
| 89 | rm -rf $BASEDIR/shaderc |
| 90 | echo "Creating local shaderc repository ($BASEDIR/shaderc)." |
| 91 | cd $BASEDIR |
Cody Northrop | bc71ca8 | 2016-11-03 14:34:17 -0600 | [diff] [blame] | 92 | git clone https://android.googlesource.com/platform/external/shaderc/shaderc |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 93 | cd shaderc |
| 94 | git checkout $SHADERC_REVISION |
| 95 | } |
| 96 | |
| 97 | function update_shaderc () { |
| 98 | echo "Updating $BASEDIR/shaderc" |
| 99 | cd $BASEDIR/shaderc |
| 100 | git fetch --all |
| 101 | git checkout $SHADERC_REVISION |
| 102 | } |
| 103 | |
| 104 | function build_shaderc () { |
| 105 | echo "Building $BASEDIR/shaderc" |
| 106 | cd $BASEDIR/shaderc/android_test |
Cody Northrop | 6e556a1 | 2016-11-03 14:35:08 -0600 | [diff] [blame] | 107 | ndk-build THIRD_PARTY_PATH=../.. -j $cores |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | if [ ! -d "$BASEDIR/glslang" -o ! -d "$BASEDIR/glslang/.git" -o -d "$BASEDIR/glslang/.svn" ]; then |
| 111 | create_glslang |
| 112 | fi |
| 113 | update_glslang |
| 114 | |
| 115 | |
| 116 | if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then |
| 117 | create_spirv-tools |
| 118 | fi |
| 119 | update_spirv-tools |
| 120 | |
Cody Northrop | 83ff93f | 2016-08-01 10:27:25 -0600 | [diff] [blame] | 121 | if [ ! -d "$BASEDIR/spirv-tools/external/spirv-headers" -o ! -d "$BASEDIR/spirv-tools/external/spirv-headers/.git" ]; then |
| 122 | create_spirv-headers |
| 123 | fi |
| 124 | update_spirv-headers |
| 125 | |
Cody Northrop | b3106db | 2016-03-29 10:06:49 -0600 | [diff] [blame] | 126 | if [ ! -d "$BASEDIR/shaderc" -o ! -d "$BASEDIR/shaderc/.git" ]; then |
| 127 | create_shaderc |
| 128 | fi |
| 129 | update_shaderc |
| 130 | build_shaderc |
| 131 | |
| 132 | echo "" |
| 133 | echo "${0##*/} finished." |
| 134 | |