blob: 2464513b78fa2e20e74f26fcdf5d3b2df773aedb [file] [log] [blame]
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -06001#!/bin/bash
Cody Northrop85d4a802015-12-29 14:42:24 -07002# Update source for glslang, LunarGLASS, spirv-tools
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -06003
Cody Northrop5934a882015-05-12 16:23:59 -06004set -e
5
6LUNARGLASS_REVISION=$(cat $PWD/LunarGLASS_revision)
7GLSLANG_REVISION=$(cat $PWD/glslang_revision)
Cody Northrop85d4a802015-12-29 14:42:24 -07008SPIRV_TOOLS_REVISION=$(cat $PWD/spirv-tools_revision)
Cody Northrop5934a882015-05-12 16:23:59 -06009echo "LUNARGLASS_REVISION=$LUNARGLASS_REVISION"
10echo "GLSLANG_REVISION=$GLSLANG_REVISION"
Cody Northrop85d4a802015-12-29 14:42:24 -070011echo "SPIRV_TOOLS_REVISION=$SPIRV_TOOLS_REVISION"
Courtney Goeltzenleuchter5120b842014-10-29 17:50:15 -060012
GregF251f0582015-09-22 17:07:37 -060013LUNARGLASS_REVISION_R32=$(cat $PWD/LunarGLASS_revision_R32)
GregF251f0582015-09-22 17:07:37 -060014echo "LUNARGLASS_REVISION_R32=$LUNARGLASS_REVISION_R32"
GregF251f0582015-09-22 17:07:37 -060015
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060016BUILDDIR=$PWD
17BASEDIR=$BUILDDIR/..
18
19function create_glslang () {
20 rm -rf $BASEDIR/glslang
Courtney Goeltzenleuchterf000ccf2015-01-07 13:35:32 -070021 echo "Creating local glslang repository ($BASEDIR/glslang)."
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060022 mkdir -p $BASEDIR/glslang
23 cd $BASEDIR/glslang
Peter Lohrmann18c06a22016-02-16 15:20:58 -080024 git clone https://github.com/KhronosGroup/glslang.git .
Courtney Goeltzenleuchtercd9f8742015-10-08 09:06:53 -060025 git checkout $GLSLANG_REVISION
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060026}
27
28function update_glslang () {
29 echo "Updating $BASEDIR/glslang"
30 cd $BASEDIR/glslang
Cody Northrop5a4883b2015-07-08 09:53:03 -060031 git fetch --all
Courtney Goeltzenleuchtercd9f8742015-10-08 09:06:53 -060032 git checkout $GLSLANG_REVISION
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060033}
34
35function create_LunarGLASS () {
36 rm -rf $BASEDIR/LunarGLASS
Courtney Goeltzenleuchterf000ccf2015-01-07 13:35:32 -070037 echo "Creating local LunarGLASS repository ($BASEDIR/LunarGLASS)."
GregF13977eb2015-09-21 17:53:57 -060038 mkdir -p $BASEDIR/LunarGLASS
39 cd $BASEDIR/LunarGLASS
40 git clone https://github.com/LunarG/LunarGLASS.git .
41 mkdir -p Core/LLVM
42 cd Core/LLVM
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060043 wget http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz
44 tar --gzip -xf llvm-3.4.src.tar.gz
GregF13977eb2015-09-21 17:53:57 -060045 git checkout -f . # put back the LunarGLASS versions of some LLVM files
46 git checkout $LUNARGLASS_REVISION
Cody Northrop2bed4c32015-10-08 09:39:57 -060047 svn checkout -r $LUNARGLASS_REVISION_R32 --force https://cvs.khronos.org/svn/repos/SPIRV/trunk/LunarGLASS/ .
GregF251f0582015-09-22 17:07:37 -060048 svn revert -R .
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060049}
50
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060051function update_LunarGLASS () {
52 echo "Updating $BASEDIR/LunarGLASS"
53 cd $BASEDIR/LunarGLASS
GregF13977eb2015-09-21 17:53:57 -060054 git fetch
GregF251f0582015-09-22 17:07:37 -060055 git checkout -f .
56 git checkout $LUNARGLASS_REVISION
GregF13977eb2015-09-21 17:53:57 -060057 # Figure out how to do this with git
GregF251f0582015-09-22 17:07:37 -060058 #git checkout $LUNARGLASS_REVISION |& tee gitout
GregF13977eb2015-09-21 17:53:57 -060059 #if grep --quiet LLVM gitout ; then
60 # rm -rf $BASEDIR/LunarGLASS/Core/LLVM/llvm-3.4/build
61 #fi
GregF251f0582015-09-22 17:07:37 -060062 #rm -rf gitout
63 if [ ! -d "$BASEDIR/LunarGLASS/.svn" ]; then
Cody Northrop2bed4c32015-10-08 09:39:57 -060064 svn checkout -r $LUNARGLASS_REVISION_R32 --force https://cvs.khronos.org/svn/repos/SPIRV/trunk/LunarGLASS/ .
GregF251f0582015-09-22 17:07:37 -060065 fi
66 svn update -r $LUNARGLASS_REVISION_R32
67 svn revert -R .
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060068}
69
Cody Northrop85d4a802015-12-29 14:42:24 -070070function create_spirv-tools () {
71 rm -rf $BASEDIR/spirv-tools
72 echo "Creating local spirv-tools repository ($BASEDIR/spirv-tools)."
73 mkdir -p $BASEDIR/spirv-tools
74 cd $BASEDIR/spirv-tools
Peter Lohrmann18c06a22016-02-16 15:20:58 -080075 git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
Cody Northrop85d4a802015-12-29 14:42:24 -070076 git checkout $SPIRV_TOOLS_REVISION
77}
78
79function update_spirv-tools () {
80 echo "Updating $BASEDIR/spirv-tools"
81 cd $BASEDIR/spirv-tools
82 git fetch --all
83 git checkout $SPIRV_TOOLS_REVISION
84}
85
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060086function build_glslang () {
Courtney Goeltzenleuchterf000ccf2015-01-07 13:35:32 -070087 echo "Building $BASEDIR/glslang"
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060088 cd $BASEDIR/glslang
89 mkdir -p build
90 cd build
91 cmake -D CMAKE_BUILD_TYPE=Release ..
92 cmake -D CMAKE_BUILD_TYPE=Release ..
93 make
94 make install
95}
96
97function build_LunarGLASS () {
Courtney Goeltzenleuchterf000ccf2015-01-07 13:35:32 -070098 echo "Building $BASEDIR/LunarGLASS"
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060099 cd $BASEDIR/LunarGLASS/Core/LLVM/llvm-3.4
100 if [ ! -d "$BASEDIR/LunarGLASS/Core/LLVM/llvm-3.4/build" ]; then
101 mkdir -p build
102 cd build
103 ../configure --enable-terminfo=no --enable-curses=no
104 REQUIRES_RTTI=1 make -j $(nproc) && make install DESTDIR=`pwd`/install
105 fi
106 cd $BASEDIR/LunarGLASS
107 mkdir -p build
108 cd build
109 cmake -D CMAKE_BUILD_TYPE=Release ..
110 cmake -D CMAKE_BUILD_TYPE=Release ..
111 make
112 make install
113}
114
Cody Northrop85d4a802015-12-29 14:42:24 -0700115function build_spirv-tools () {
116 echo "Building $BASEDIR/spirv-tools"
117 cd $BASEDIR/spirv-tools
118 mkdir -p build
119 cd build
120 cmake -D CMAKE_BUILD_TYPE=Release ..
121 make -j $(nproc)
122}
123
Cody Northrop73f0fd72015-12-29 16:25:10 -0700124# If any options are provided, just compile those tools
125# If no options are provided, build everything
126INCLUDE_GLSLANG=false
127INCLUDE_LUNARGLASS=false
128INCLUDE_SPIRV_TOOLS=false
Cody Northrope2905f62015-11-30 13:40:50 -0700129
Cody Northrop73f0fd72015-12-29 16:25:10 -0700130if [ "$#" == 0 ]; then
131 echo "Building glslang, LunarGLASS, spirv-tools"
132 INCLUDE_GLSLANG=true
133 INCLUDE_LUNARGLASS=true
134 INCLUDE_SPIRV_TOOLS=true
135else
136 # Parse options
137 while [[ $# > 0 ]]
138 do
139 option="$1"
Cody Northrope2905f62015-11-30 13:40:50 -0700140
Cody Northrop73f0fd72015-12-29 16:25:10 -0700141 case $option in
142 # options to specify build of glslang components
143 -g|--glslang)
144 INCLUDE_GLSLANG=true
145 echo "Building glslang ($option)"
146 ;;
147 # options to specify build of LunarGLASS components
148 -l|--LunarGLASS)
149 INCLUDE_LUNARGLASS=true
150 echo "Building LunarGLASS ($option)"
151 ;;
152 # options to specify build of spirv-tools components
153 -s|--spirv-tools)
154 INCLUDE_SPIRV_TOOLS=true
155 echo "Building spirv-tools ($option)"
156 ;;
157 *)
158 echo "Unrecognized option: $option"
159 echo "Try the following:"
160 echo " -g | --glslang # enable glslang"
161 echo " -l | --LunarGLASS # enable LunarGLASS"
162 echo " -s | --spirv-tools # enable spirv-tools"
163 exit 1
164 ;;
165 esac
166 shift
167 done
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -0600168fi
Cody Northrope2905f62015-11-30 13:40:50 -0700169
Cody Northrop73f0fd72015-12-29 16:25:10 -0700170if [ $INCLUDE_GLSLANG == "true" ]; then
171 if [ ! -d "$BASEDIR/glslang" -o ! -d "$BASEDIR/glslang/.git" -o -d "$BASEDIR/glslang/.svn" ]; then
172 create_glslang
173 fi
174 update_glslang
175 build_glslang
176fi
177
178
179if [ $INCLUDE_LUNARGLASS == "true" ]; then
Cody Northrope2905f62015-11-30 13:40:50 -0700180 if [ ! -d "$BASEDIR/LunarGLASS" -o ! -d "$BASEDIR/LunarGLASS/.git" ]; then
181 create_LunarGLASS
182 fi
Cody Northrop73f0fd72015-12-29 16:25:10 -0700183 update_LunarGLASS
184 build_LunarGLASS
185fi
186
187if [ $INCLUDE_SPIRV_TOOLS == "true" ]; then
Cody Northrop85d4a802015-12-29 14:42:24 -0700188 if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then
189 create_spirv-tools
190 fi
Cody Northrop85d4a802015-12-29 14:42:24 -0700191 update_spirv-tools
Cody Northrop85d4a802015-12-29 14:42:24 -0700192 build_spirv-tools
Cody Northrope2905f62015-11-30 13:40:50 -0700193fi