blob: d3702ec9528160f176b60a9f9f45949abce42da7 [file] [log] [blame]
Courtney Goeltzenleuchter87094962014-10-17 18:21:42 -06001#!/bin/bash
Cody Northrop983c1fa2015-12-29 14:42:24 -07002# Update source for glslang, LunarGLASS, spirv-tools
Courtney Goeltzenleuchter87094962014-10-17 18:21:42 -06003
Cody Northropa8ac1352015-05-12 16:23:59 -06004set -e
5
Cody Northropa8ac1352015-05-12 16:23:59 -06006GLSLANG_REVISION=$(cat $PWD/glslang_revision)
Cody Northrop983c1fa2015-12-29 14:42:24 -07007SPIRV_TOOLS_REVISION=$(cat $PWD/spirv-tools_revision)
Cody Northropa8ac1352015-05-12 16:23:59 -06008echo "GLSLANG_REVISION=$GLSLANG_REVISION"
Cody Northrop983c1fa2015-12-29 14:42:24 -07009echo "SPIRV_TOOLS_REVISION=$SPIRV_TOOLS_REVISION"
Courtney Goeltzenleuchter90a6f4b2014-10-29 17:50:15 -060010
Courtney Goeltzenleuchter87094962014-10-17 18:21:42 -060011BUILDDIR=$PWD
12BASEDIR=$BUILDDIR/..
13
14function create_glslang () {
15 rm -rf $BASEDIR/glslang
Courtney Goeltzenleuchter4f572612015-01-07 13:35:32 -070016 echo "Creating local glslang repository ($BASEDIR/glslang)."
Courtney Goeltzenleuchter87094962014-10-17 18:21:42 -060017 mkdir -p $BASEDIR/glslang
18 cd $BASEDIR/glslang
Peter Lohrmann5d93b0d2016-02-16 15:20:58 -080019 git clone https://github.com/KhronosGroup/glslang.git .
Courtney Goeltzenleuchter6885ef22015-10-08 09:06:53 -060020 git checkout $GLSLANG_REVISION
Courtney Goeltzenleuchter87094962014-10-17 18:21:42 -060021}
22
23function update_glslang () {
24 echo "Updating $BASEDIR/glslang"
25 cd $BASEDIR/glslang
Cody Northrop139ec4f2015-07-08 09:53:03 -060026 git fetch --all
Courtney Goeltzenleuchter6885ef22015-10-08 09:06:53 -060027 git checkout $GLSLANG_REVISION
Courtney Goeltzenleuchter87094962014-10-17 18:21:42 -060028}
29
Cody Northrop983c1fa2015-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 Lohrmann5d93b0d2016-02-16 15:20:58 -080035 git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
Cody Northrop983c1fa2015-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 Goeltzenleuchter87094962014-10-17 18:21:42 -060046function build_glslang () {
Courtney Goeltzenleuchter4f572612015-01-07 13:35:32 -070047 echo "Building $BASEDIR/glslang"
Courtney Goeltzenleuchter87094962014-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 Northrop983c1fa2015-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 Northrop2f865b32015-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 Northrop2f865b32015-12-29 16:25:10 -070069INCLUDE_SPIRV_TOOLS=false
Cody Northrop26f29c02015-11-30 13:40:50 -070070
Cody Northrop2f865b32015-12-29 16:25:10 -070071if [ "$#" == 0 ]; then
GregF211374b2016-02-19 11:50:05 -070072 echo "Building glslang, spirv-tools"
Cody Northrop2f865b32015-12-29 16:25:10 -070073 INCLUDE_GLSLANG=true
Cody Northrop2f865b32015-12-29 16:25:10 -070074 INCLUDE_SPIRV_TOOLS=true
75else
76 # Parse options
77 while [[ $# > 0 ]]
78 do
79 option="$1"
Cody Northrop26f29c02015-11-30 13:40:50 -070080
Cody Northrop2f865b32015-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 Northrop2f865b32015-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 Northrop2f865b32015-12-29 16:25:10 -070096 echo " -s | --spirv-tools # enable spirv-tools"
97 exit 1
98 ;;
99 esac
100 shift
101 done
Courtney Goeltzenleuchter87094962014-10-17 18:21:42 -0600102fi
Cody Northrop26f29c02015-11-30 13:40:50 -0700103
Cody Northrop2f865b32015-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 Northrop2f865b32015-12-29 16:25:10 -0700113if [ $INCLUDE_SPIRV_TOOLS == "true" ]; then
Cody Northrop983c1fa2015-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 Northrop983c1fa2015-12-29 14:42:24 -0700117 update_spirv-tools
Cody Northrop983c1fa2015-12-29 14:42:24 -0700118 build_spirv-tools
Cody Northrop26f29c02015-11-30 13:40:50 -0700119fi