Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 1 | #!/bin/bash |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 2 | # Update source for glslang, LunarGLASS, spirv-tools |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 3 | |
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 4 | set -e |
| 5 | |
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 6 | GLSLANG_REVISION=$(cat $PWD/glslang_revision) |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 7 | SPIRV_TOOLS_REVISION=$(cat $PWD/spirv-tools_revision) |
Cody Northrop | 5934a88 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 8 | echo "GLSLANG_REVISION=$GLSLANG_REVISION" |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 9 | echo "SPIRV_TOOLS_REVISION=$SPIRV_TOOLS_REVISION" |
Courtney Goeltzenleuchter | 5120b84 | 2014-10-29 17:50:15 -0600 | [diff] [blame] | 10 | |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 11 | BUILDDIR=$PWD |
Jon Ashburn | 17c6468 | 2016-05-02 08:39:14 -0600 | [diff] [blame] | 12 | BASEDIR=$BUILDDIR/external |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 13 | |
| 14 | function create_glslang () { |
| 15 | rm -rf $BASEDIR/glslang |
Courtney Goeltzenleuchter | f000ccf | 2015-01-07 13:35:32 -0700 | [diff] [blame] | 16 | echo "Creating local glslang repository ($BASEDIR/glslang)." |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 17 | mkdir -p $BASEDIR/glslang |
| 18 | cd $BASEDIR/glslang |
Peter Lohrmann | 18c06a2 | 2016-02-16 15:20:58 -0800 | [diff] [blame] | 19 | git clone https://github.com/KhronosGroup/glslang.git . |
Courtney Goeltzenleuchter | cd9f874 | 2015-10-08 09:06:53 -0600 | [diff] [blame] | 20 | git checkout $GLSLANG_REVISION |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | function update_glslang () { |
| 24 | echo "Updating $BASEDIR/glslang" |
| 25 | cd $BASEDIR/glslang |
Cody Northrop | 5a4883b | 2015-07-08 09:53:03 -0600 | [diff] [blame] | 26 | git fetch --all |
Courtney Goeltzenleuchter | cd9f874 | 2015-10-08 09:06:53 -0600 | [diff] [blame] | 27 | git checkout $GLSLANG_REVISION |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 28 | } |
| 29 | |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 30 | function 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 Lohrmann | 18c06a2 | 2016-02-16 15:20:58 -0800 | [diff] [blame] | 35 | git clone https://github.com/KhronosGroup/SPIRV-Tools.git . |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 36 | git checkout $SPIRV_TOOLS_REVISION |
GregF | 2d39538 | 2016-06-17 12:26:49 -0600 | [diff] [blame] | 37 | mkdir -p $BASEDIR/spirv-tools/external/spirv-headers |
| 38 | cd $BASEDIR/spirv-tools/external/spirv-headers |
| 39 | git clone https://github.com/KhronosGroup/SPIRV-Headers . |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | function update_spirv-tools () { |
| 43 | echo "Updating $BASEDIR/spirv-tools" |
| 44 | cd $BASEDIR/spirv-tools |
| 45 | git fetch --all |
| 46 | git checkout $SPIRV_TOOLS_REVISION |
GregF | 2d39538 | 2016-06-17 12:26:49 -0600 | [diff] [blame] | 47 | if [ ! -d "$BASEDIR/spirv-tools/external/spirv-headers" -o ! -d "$BASEDIR/spirv-tools/external/spirv-headers/.git" ]; then |
| 48 | mkdir -p $BASEDIR/spirv-tools/external/spirv-headers |
| 49 | cd $BASEDIR/spirv-tools/external/spirv-headers |
| 50 | git clone https://github.com/KhronosGroup/SPIRV-Headers . |
| 51 | else |
| 52 | cd $BASEDIR/spirv-tools/external/spirv-headers |
| 53 | git fetch --all |
| 54 | git pull |
| 55 | fi |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 58 | function build_glslang () { |
Courtney Goeltzenleuchter | f000ccf | 2015-01-07 13:35:32 -0700 | [diff] [blame] | 59 | echo "Building $BASEDIR/glslang" |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 60 | cd $BASEDIR/glslang |
| 61 | mkdir -p build |
| 62 | cd build |
| 63 | cmake -D CMAKE_BUILD_TYPE=Release .. |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 64 | make |
| 65 | make install |
| 66 | } |
| 67 | |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 68 | function build_spirv-tools () { |
| 69 | echo "Building $BASEDIR/spirv-tools" |
| 70 | cd $BASEDIR/spirv-tools |
| 71 | mkdir -p build |
| 72 | cd build |
| 73 | cmake -D CMAKE_BUILD_TYPE=Release .. |
| 74 | make -j $(nproc) |
| 75 | } |
| 76 | |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 77 | # If any options are provided, just compile those tools |
| 78 | # If no options are provided, build everything |
| 79 | INCLUDE_GLSLANG=false |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 80 | INCLUDE_SPIRV_TOOLS=false |
Cody Northrop | e2905f6 | 2015-11-30 13:40:50 -0700 | [diff] [blame] | 81 | |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 82 | if [ "$#" == 0 ]; then |
GregF | 149e6c6 | 2016-02-19 11:50:05 -0700 | [diff] [blame] | 83 | echo "Building glslang, spirv-tools" |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 84 | INCLUDE_GLSLANG=true |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 85 | INCLUDE_SPIRV_TOOLS=true |
| 86 | else |
| 87 | # Parse options |
| 88 | while [[ $# > 0 ]] |
| 89 | do |
| 90 | option="$1" |
Cody Northrop | e2905f6 | 2015-11-30 13:40:50 -0700 | [diff] [blame] | 91 | |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 92 | case $option in |
| 93 | # options to specify build of glslang components |
| 94 | -g|--glslang) |
| 95 | INCLUDE_GLSLANG=true |
| 96 | echo "Building glslang ($option)" |
| 97 | ;; |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 98 | # options to specify build of spirv-tools components |
| 99 | -s|--spirv-tools) |
| 100 | INCLUDE_SPIRV_TOOLS=true |
| 101 | echo "Building spirv-tools ($option)" |
| 102 | ;; |
| 103 | *) |
| 104 | echo "Unrecognized option: $option" |
| 105 | echo "Try the following:" |
| 106 | echo " -g | --glslang # enable glslang" |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 107 | echo " -s | --spirv-tools # enable spirv-tools" |
| 108 | exit 1 |
| 109 | ;; |
| 110 | esac |
| 111 | shift |
| 112 | done |
Courtney Goeltzenleuchter | 7f0a7be | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 113 | fi |
Cody Northrop | e2905f6 | 2015-11-30 13:40:50 -0700 | [diff] [blame] | 114 | |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 115 | if [ $INCLUDE_GLSLANG == "true" ]; then |
| 116 | if [ ! -d "$BASEDIR/glslang" -o ! -d "$BASEDIR/glslang/.git" -o -d "$BASEDIR/glslang/.svn" ]; then |
| 117 | create_glslang |
| 118 | fi |
| 119 | update_glslang |
| 120 | build_glslang |
| 121 | fi |
| 122 | |
| 123 | |
Cody Northrop | 73f0fd7 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 124 | if [ $INCLUDE_SPIRV_TOOLS == "true" ]; then |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 125 | if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then |
| 126 | create_spirv-tools |
| 127 | fi |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 128 | update_spirv-tools |
Cody Northrop | 85d4a80 | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 129 | build_spirv-tools |
Cody Northrop | e2905f6 | 2015-11-30 13:40:50 -0700 | [diff] [blame] | 130 | fi |