blob: 183ed136c4be441c0cd9f590ef251b691aac1247 [file] [log] [blame]
Cody Northropb3106db2016-03-29 10:06:49 -06001#!/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
19set -e
20
21ANDROIDBUILDDIR=$PWD
Cody Northrop544a42e2016-11-03 14:44:55 -060022BUILDDIR=$ANDROIDBUILDDIR
Cody Northrop217d23c2016-05-03 15:38:05 -060023BASEDIR=$BUILDDIR/external
Cody Northropb3106db2016-03-29 10:06:49 -060024
Cody Northrop4bf55d72016-03-31 16:33:00 -060025GLSLANG_REVISION=$(cat $ANDROIDBUILDDIR/glslang_revision_android)
26SPIRV_TOOLS_REVISION=$(cat $ANDROIDBUILDDIR/spirv-tools_revision_android)
Cody Northrop83ff93f2016-08-01 10:27:25 -060027SPIRV_HEADERS_REVISION=$(cat $ANDROIDBUILDDIR/spirv-headers_revision_android)
Cody Northrop4bf55d72016-03-31 16:33:00 -060028SHADERC_REVISION=$(cat $ANDROIDBUILDDIR/shaderc_revision_android)
Cody Northropb3106db2016-03-29 10:06:49 -060029
30echo "GLSLANG_REVISION=$GLSLANG_REVISION"
31echo "SPIRV_TOOLS_REVISION=$SPIRV_TOOLS_REVISION"
32echo "SHADERC_REVISION=$SHADERC_REVISION"
33
Cody Northrop6e556a12016-11-03 14:35:08 -060034if [[ $(uname) == "Linux" ]]; then
Cody Northropfee2dfa2016-11-14 15:48:08 -070035 cores=$(ncpus || echo 4)
Cody Northrop6e556a12016-11-03 14:35:08 -060036elif [[ $(uname) == "Darwin" ]]; then
37 cores=$(sysctl -n hw.ncpu)
38fi
39
Cody Northropb3106db2016-03-29 10:06:49 -060040function 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 Northropbc71ca82016-11-03 14:34:17 -060045 git clone https://android.googlesource.com/platform/external/shaderc/glslang .
Cody Northropb3106db2016-03-29 10:06:49 -060046 git checkout $GLSLANG_REVISION
47}
48
49function update_glslang () {
50 echo "Updating $BASEDIR/glslang"
51 cd $BASEDIR/glslang
52 git fetch --all
53 git checkout $GLSLANG_REVISION
54}
55
56function 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 Northropbc71ca82016-11-03 14:34:17 -060061 git clone https://android.googlesource.com/platform/external/shaderc/spirv-tools .
Cody Northropb3106db2016-03-29 10:06:49 -060062 git checkout $SPIRV_TOOLS_REVISION
63}
64
65function 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 Northrop83ff93f2016-08-01 10:27:25 -060072function 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 Northropbc71ca82016-11-03 14:34:17 -060077 git clone https://android.googlesource.com/platform/external/shaderc/spirv-headers .
Cody Northrop83ff93f2016-08-01 10:27:25 -060078 git checkout $SPIRV_HEADERS_REVISION
79}
80
81function 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 Northropb3106db2016-03-29 10:06:49 -060088function create_shaderc () {
89 rm -rf $BASEDIR/shaderc
90 echo "Creating local shaderc repository ($BASEDIR/shaderc)."
91 cd $BASEDIR
Cody Northropbc71ca82016-11-03 14:34:17 -060092 git clone https://android.googlesource.com/platform/external/shaderc/shaderc
Cody Northropb3106db2016-03-29 10:06:49 -060093 cd shaderc
94 git checkout $SHADERC_REVISION
95}
96
97function update_shaderc () {
98 echo "Updating $BASEDIR/shaderc"
99 cd $BASEDIR/shaderc
100 git fetch --all
101 git checkout $SHADERC_REVISION
102}
103
104function build_shaderc () {
105 echo "Building $BASEDIR/shaderc"
106 cd $BASEDIR/shaderc/android_test
Cody Northrop6e556a12016-11-03 14:35:08 -0600107 ndk-build THIRD_PARTY_PATH=../.. -j $cores
Cody Northropb3106db2016-03-29 10:06:49 -0600108}
109
110if [ ! -d "$BASEDIR/glslang" -o ! -d "$BASEDIR/glslang/.git" -o -d "$BASEDIR/glslang/.svn" ]; then
111 create_glslang
112fi
113 update_glslang
114
115
116if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then
117 create_spirv-tools
118fi
119update_spirv-tools
120
Cody Northrop83ff93f2016-08-01 10:27:25 -0600121if [ ! -d "$BASEDIR/spirv-tools/external/spirv-headers" -o ! -d "$BASEDIR/spirv-tools/external/spirv-headers/.git" ]; then
122 create_spirv-headers
123fi
124update_spirv-headers
125
Cody Northropb3106db2016-03-29 10:06:49 -0600126if [ ! -d "$BASEDIR/shaderc" -o ! -d "$BASEDIR/shaderc/.git" ]; then
127 create_shaderc
128fi
129update_shaderc
130build_shaderc
131
132echo ""
133echo "${0##*/} finished."
134