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