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