| Courtney Goeltzenleuchter | 8709496 | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 1 | #!/bin/bash | 
| Cody Northrop | 983c1fa | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 2 | # Update source for glslang, LunarGLASS, spirv-tools | 
| Courtney Goeltzenleuchter | 8709496 | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 3 |  | 
| Cody Northrop | a8ac135 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 4 | set -e | 
 | 5 |  | 
| Cody Northrop | a8ac135 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 6 | GLSLANG_REVISION=$(cat $PWD/glslang_revision) | 
| Cody Northrop | 983c1fa | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 7 | SPIRV_TOOLS_REVISION=$(cat $PWD/spirv-tools_revision) | 
| Cody Northrop | a8ac135 | 2015-05-12 16:23:59 -0600 | [diff] [blame] | 8 | echo "GLSLANG_REVISION=$GLSLANG_REVISION" | 
| Cody Northrop | 983c1fa | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 9 | echo "SPIRV_TOOLS_REVISION=$SPIRV_TOOLS_REVISION" | 
| Courtney Goeltzenleuchter | 90a6f4b | 2014-10-29 17:50:15 -0600 | [diff] [blame] | 10 |  | 
| Courtney Goeltzenleuchter | 8709496 | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 11 | BUILDDIR=$PWD | 
 | 12 | BASEDIR=$BUILDDIR/.. | 
 | 13 |  | 
 | 14 | function create_glslang () { | 
 | 15 |    rm -rf $BASEDIR/glslang | 
| Courtney Goeltzenleuchter | 4f57261 | 2015-01-07 13:35:32 -0700 | [diff] [blame] | 16 |    echo "Creating local glslang repository ($BASEDIR/glslang)." | 
| Courtney Goeltzenleuchter | 8709496 | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 17 |    mkdir -p $BASEDIR/glslang | 
 | 18 |    cd $BASEDIR/glslang | 
| Peter Lohrmann | 5d93b0d | 2016-02-16 15:20:58 -0800 | [diff] [blame] | 19 |    git clone https://github.com/KhronosGroup/glslang.git . | 
| Courtney Goeltzenleuchter | 6885ef2 | 2015-10-08 09:06:53 -0600 | [diff] [blame] | 20 |    git checkout $GLSLANG_REVISION | 
| Courtney Goeltzenleuchter | 8709496 | 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 | 139ec4f | 2015-07-08 09:53:03 -0600 | [diff] [blame] | 26 |    git fetch --all | 
| Courtney Goeltzenleuchter | 6885ef2 | 2015-10-08 09:06:53 -0600 | [diff] [blame] | 27 |    git checkout $GLSLANG_REVISION | 
| Courtney Goeltzenleuchter | 8709496 | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 28 | } | 
 | 29 |  | 
| Cody Northrop | 983c1fa | 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 | 5d93b0d | 2016-02-16 15:20:58 -0800 | [diff] [blame] | 35 |    git clone https://github.com/KhronosGroup/SPIRV-Tools.git . | 
| Cody Northrop | 983c1fa | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 36 |    git checkout $SPIRV_TOOLS_REVISION | 
 | 37 | } | 
 | 38 |  | 
 | 39 | function 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 Goeltzenleuchter | 8709496 | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 46 | function build_glslang () { | 
| Courtney Goeltzenleuchter | 4f57261 | 2015-01-07 13:35:32 -0700 | [diff] [blame] | 47 |    echo "Building $BASEDIR/glslang" | 
| Courtney Goeltzenleuchter | 8709496 | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 48 |    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 Northrop | 983c1fa | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 57 | function 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 Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 66 | # If any options are provided, just compile those tools | 
 | 67 | # If no options are provided, build everything | 
 | 68 | INCLUDE_GLSLANG=false | 
| Cody Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 69 | INCLUDE_SPIRV_TOOLS=false | 
| Cody Northrop | 26f29c0 | 2015-11-30 13:40:50 -0700 | [diff] [blame] | 70 |  | 
| Cody Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 71 | if [ "$#" == 0 ]; then | 
| GregF | 211374b | 2016-02-19 11:50:05 -0700 | [diff] [blame] | 72 |   echo "Building glslang, spirv-tools" | 
| Cody Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 73 |   INCLUDE_GLSLANG=true | 
| Cody Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 74 |   INCLUDE_SPIRV_TOOLS=true | 
 | 75 | else | 
 | 76 |   # Parse options | 
 | 77 |   while [[ $# > 0 ]] | 
 | 78 |   do | 
 | 79 |     option="$1" | 
| Cody Northrop | 26f29c0 | 2015-11-30 13:40:50 -0700 | [diff] [blame] | 80 |  | 
| Cody Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 81 |     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 Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 87 |         # 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 Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 96 |         echo " -s | --spirv-tools  # enable spirv-tools" | 
 | 97 |         exit 1 | 
 | 98 |         ;; | 
 | 99 |     esac | 
 | 100 |     shift | 
 | 101 |   done | 
| Courtney Goeltzenleuchter | 8709496 | 2014-10-17 18:21:42 -0600 | [diff] [blame] | 102 | fi | 
| Cody Northrop | 26f29c0 | 2015-11-30 13:40:50 -0700 | [diff] [blame] | 103 |  | 
| Cody Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 104 | if [ $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 | 
 | 110 | fi | 
 | 111 |  | 
 | 112 |  | 
| Cody Northrop | 2f865b3 | 2015-12-29 16:25:10 -0700 | [diff] [blame] | 113 | if [ $INCLUDE_SPIRV_TOOLS == "true" ]; then | 
| Cody Northrop | 983c1fa | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 114 |     if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then | 
 | 115 |        create_spirv-tools | 
 | 116 |     fi | 
| Cody Northrop | 983c1fa | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 117 |     update_spirv-tools | 
| Cody Northrop | 983c1fa | 2015-12-29 14:42:24 -0700 | [diff] [blame] | 118 |     build_spirv-tools | 
| Cody Northrop | 26f29c0 | 2015-11-30 13:40:50 -0700 | [diff] [blame] | 119 | fi |