blob: d3702ec9528160f176b60a9f9f45949abce42da7 [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
Cody Northrop5934a882015-05-12 16:23:59 -06006GLSLANG_REVISION=$(cat $PWD/glslang_revision)
Cody Northrop85d4a802015-12-29 14:42:24 -07007SPIRV_TOOLS_REVISION=$(cat $PWD/spirv-tools_revision)
Cody Northrop5934a882015-05-12 16:23:59 -06008echo "GLSLANG_REVISION=$GLSLANG_REVISION"
Cody Northrop85d4a802015-12-29 14:42:24 -07009echo "SPIRV_TOOLS_REVISION=$SPIRV_TOOLS_REVISION"
Courtney Goeltzenleuchter5120b842014-10-29 17:50:15 -060010
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060011BUILDDIR=$PWD
12BASEDIR=$BUILDDIR/..
13
14function create_glslang () {
15 rm -rf $BASEDIR/glslang
Courtney Goeltzenleuchterf000ccf2015-01-07 13:35:32 -070016 echo "Creating local glslang repository ($BASEDIR/glslang)."
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060017 mkdir -p $BASEDIR/glslang
18 cd $BASEDIR/glslang
Peter Lohrmann18c06a22016-02-16 15:20:58 -080019 git clone https://github.com/KhronosGroup/glslang.git .
Courtney Goeltzenleuchtercd9f8742015-10-08 09:06:53 -060020 git checkout $GLSLANG_REVISION
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060021}
22
23function update_glslang () {
24 echo "Updating $BASEDIR/glslang"
25 cd $BASEDIR/glslang
Cody Northrop5a4883b2015-07-08 09:53:03 -060026 git fetch --all
Courtney Goeltzenleuchtercd9f8742015-10-08 09:06:53 -060027 git checkout $GLSLANG_REVISION
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060028}
29
Cody Northrop85d4a802015-12-29 14:42:24 -070030function create_spirv-tools () {
31 rm -rf $BASEDIR/spirv-tools
32 echo "Creating local spirv-tools repository ($BASEDIR/spirv-tools)."
33 mkdir -p $BASEDIR/spirv-tools
34 cd $BASEDIR/spirv-tools
Peter Lohrmann18c06a22016-02-16 15:20:58 -080035 git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
Cody Northrop85d4a802015-12-29 14:42:24 -070036 git checkout $SPIRV_TOOLS_REVISION
37}
38
39function update_spirv-tools () {
40 echo "Updating $BASEDIR/spirv-tools"
41 cd $BASEDIR/spirv-tools
42 git fetch --all
43 git checkout $SPIRV_TOOLS_REVISION
44}
45
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060046function build_glslang () {
Courtney Goeltzenleuchterf000ccf2015-01-07 13:35:32 -070047 echo "Building $BASEDIR/glslang"
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -060048 cd $BASEDIR/glslang
49 mkdir -p build
50 cd build
51 cmake -D CMAKE_BUILD_TYPE=Release ..
52 cmake -D CMAKE_BUILD_TYPE=Release ..
53 make
54 make install
55}
56
Cody Northrop85d4a802015-12-29 14:42:24 -070057function build_spirv-tools () {
58 echo "Building $BASEDIR/spirv-tools"
59 cd $BASEDIR/spirv-tools
60 mkdir -p build
61 cd build
62 cmake -D CMAKE_BUILD_TYPE=Release ..
63 make -j $(nproc)
64}
65
Cody Northrop73f0fd72015-12-29 16:25:10 -070066# If any options are provided, just compile those tools
67# If no options are provided, build everything
68INCLUDE_GLSLANG=false
Cody Northrop73f0fd72015-12-29 16:25:10 -070069INCLUDE_SPIRV_TOOLS=false
Cody Northrope2905f62015-11-30 13:40:50 -070070
Cody Northrop73f0fd72015-12-29 16:25:10 -070071if [ "$#" == 0 ]; then
GregF149e6c62016-02-19 11:50:05 -070072 echo "Building glslang, spirv-tools"
Cody Northrop73f0fd72015-12-29 16:25:10 -070073 INCLUDE_GLSLANG=true
Cody Northrop73f0fd72015-12-29 16:25:10 -070074 INCLUDE_SPIRV_TOOLS=true
75else
76 # Parse options
77 while [[ $# > 0 ]]
78 do
79 option="$1"
Cody Northrope2905f62015-11-30 13:40:50 -070080
Cody Northrop73f0fd72015-12-29 16:25:10 -070081 case $option in
82 # options to specify build of glslang components
83 -g|--glslang)
84 INCLUDE_GLSLANG=true
85 echo "Building glslang ($option)"
86 ;;
Cody Northrop73f0fd72015-12-29 16:25:10 -070087 # options to specify build of spirv-tools components
88 -s|--spirv-tools)
89 INCLUDE_SPIRV_TOOLS=true
90 echo "Building spirv-tools ($option)"
91 ;;
92 *)
93 echo "Unrecognized option: $option"
94 echo "Try the following:"
95 echo " -g | --glslang # enable glslang"
Cody Northrop73f0fd72015-12-29 16:25:10 -070096 echo " -s | --spirv-tools # enable spirv-tools"
97 exit 1
98 ;;
99 esac
100 shift
101 done
Courtney Goeltzenleuchter7f0a7be2014-10-17 18:21:42 -0600102fi
Cody Northrope2905f62015-11-30 13:40:50 -0700103
Cody Northrop73f0fd72015-12-29 16:25:10 -0700104if [ $INCLUDE_GLSLANG == "true" ]; then
105 if [ ! -d "$BASEDIR/glslang" -o ! -d "$BASEDIR/glslang/.git" -o -d "$BASEDIR/glslang/.svn" ]; then
106 create_glslang
107 fi
108 update_glslang
109 build_glslang
110fi
111
112
Cody Northrop73f0fd72015-12-29 16:25:10 -0700113if [ $INCLUDE_SPIRV_TOOLS == "true" ]; then
Cody Northrop85d4a802015-12-29 14:42:24 -0700114 if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then
115 create_spirv-tools
116 fi
Cody Northrop85d4a802015-12-29 14:42:24 -0700117 update_spirv-tools
Cody Northrop85d4a802015-12-29 14:42:24 -0700118 build_spirv-tools
Cody Northrope2905f62015-11-30 13:40:50 -0700119fi