yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
626e81478
master
1#!/usr/bin/env bash 2 3set -e 4 5EXTERNAL_DIR =" $( cd " $( dirname " ${ BASH_SOURCE [0]} " ) " > /dev/null 2 >&1 && pwd ) " 6 7refDef =refs/heads/main 8ref =$ refDef 9upstreamDef =https://github.com/KhronosGroup/glslang 10upstream =$ upstreamDef 11 12while [[" $ #" -gt 0 ]];do 13case $ 1 in 14 -h| --help)help =1 ;; 15 --release) 16ref ="refs/tags/ $ 2 " 17shift 18 ;; 19 --ref) 20ref =" $ 2 " 21shift 22 ;; 23 --upstream) 24upstream =" $ 2 " 25shift 26 ;; 27 --do-commit) 28do_commit =1 29 ;; 30 --do-fetch) 31do_fetch =1 32 ;; 33 *) 34echo "Unknown parameter passed: $ 1 " >&2 35exit 1 36 ;; 37esac 38shift 39done 40 41if [" $ help " ];then 42me =$( basename " $ 0" ) 43cat <<EOF 44$ me : Update external/glslang and dependencies 45 46- Merge the latest upstream glslang (or a specified commit) 47- Checkout the 'known good' revision of and spirv-headers 48- Merge the 'known_good' revision of spirv-tools with our changes 49- Regenerate the contents of external/glslang-generated and external/spirv-tools-generated 50- Optionally commit the changes 51 52Options: 53--do-fetch : Fetch new changes to glslang spirv-tools spirv-headers, if 54this isn't specified then the ref/release/upstream options do 55nothing 56 57--ref 2b2523f : merge this specific commit into our branch 58defaults to $ refDef 59 60--release foo : short for --ref refs/tags/foo 61 62--upstream https://example.com/glslang 63: Specify the url of the repo from which to merge 64defaults to $ upstreamDef 65 66--do-commit : Commit the changes to git 67 68EOF 69exit 70fi 71 72big_msg () { 73echo 74echo "################################################################" 75echo " $ 1 " 76echo "################################################################" 77} 78 79require_bin () { 80if !command -v " $ 1 " &>/dev/null;then 81echo "This script needs $ 1 , but it isn't in \$PATH" 82missing_bin =1 83fi 84} 85require_bin "jq" 86require_bin "git" 87require_bin "python" 88require_bin "cmake" 89if [" $ missing_bin " ];then 90exit 1 91fi 92 93glslang =$ EXTERNAL_DIR /glslang 94glslang_generated =$ EXTERNAL_DIR /glslang-generated 95spirv_headers =$ EXTERNAL_DIR /spirv-headers 96spirv_tools =$ EXTERNAL_DIR /spirv-tools 97spirv_tools_generated =$ EXTERNAL_DIR /spirv-tools-generated 98effcee =$ spirv_tools /external/effcee 99absl =$ spirv_tools /external/effcee/third_party/abseil_cpp 100re2 =$ spirv_tools /external/re2 101 102if !test -f " $ glslang /.git" ;then 103echo " $ glslang doesn't appear to be a git repo" 104echo "Perhaps you need to 'git submodule update --init'" 105exit 1 106fi 107 108known_good_commit () { 109jq < " $ glslang /known_good.json" \ 110".commits | .[] | select(.name == \" $ 1 \") | .commit" \ 111 --raw-output 112} 113 114bump_dep () { 115commit =$( known_good_commit " $ 2 " ) 116big_msg "Fetching $ commit from origin in $ 1 " 117git -C " $ 1 " fetch origin" $ commit " 118big_msg "Checking out $ commit in $ 1 " 119git -C " $ 1 " checkout" $ commit " 120} 121 122declare -Aold_ref 123declare -Anew_ref 124merge_dep () { 125name =$ 1 126dir =$ 2 127up =$ 3 128r =$ 4 129old_ref [" $ 1 " ]=$( git -C " $ dir " describe --exclude master-tot --tags HEAD) 130big_msg "Fetching $ name $ r from $ up " 131git -C " $ dir " fetch--tags --force " $ up " 132git -C " $ dir " fetch" $ up " " $ r " 133big_msg "Merging $ r into our branch" 134git -C " $ dir " merge--no-edit FETCH_HEAD 135new_ref [" $ 1 " ]=$( git -C " $ dir " describe --exclude master-tot --tags HEAD) 136} 137 138if [" $ do_fetch " ];then 139merge_dep glslang" $ glslang " " $ upstream " " $ ref " 140 141spirv_tools_upstream =https://github.com/$( 142jq < " $ glslang /known_good.json" \ 143".commits | .[] | select(.name == \"spirv-tools\") | .subrepo" \ 144--raw-output 145) 146 147merge_dep spirv-tools" $ spirv_tools " " $ spirv_tools_upstream " " $( known_good_commit "spirv-tools" ) " 148 149bump_dep " $ spirv_headers " "spirv-tools/external/spirv-headers" 150fi 151 152# Make sure we have the dependencies of spirv-tools up to date 153 154test -d " $ effcee " ||git clone https://github.com/google/effcee.git" $ effcee " 155git -C " $ effcee " pull 156 157test -d " $ absl " ||git clone https://github.com/abseil/abseil-cpp" $ absl " 158git -C " $ absl " pull 159 160test -d " $ re2 " ||git clone https://github.com/google/re2.git" $ re2 " 161git -C " $ re2 " pull 162 163rm -rf " $ spirv_tools /external/spirv-headers" 164ln -s " $ spirv_headers " " $ spirv_tools /external/spirv-headers" 165 166# 167# We have now checked out everything, time to generate the files for 168# glslang-generated and friends. 169# 170 171big_msg "Generating files for glslang-generated" 172set -x 173(cd " $ glslang " && python build_info.py .-i build_info.h.tmpl-o " $ glslang_generated " /glslang/build_info.h) 174set +x 175 176big_msg "Generating files for spirv-tools" 177build =" $ spirv_tools /build" 178mkdir -p " $ build " 179echo "Building spirv-tools" 180cmake -Wno-dev -B " $ build " " $ spirv_tools " 181# These are the targets which generate .inc and .h files (just what we need, 182# specify them here to avoid a lengthy compile) 183cmake --build " $ build " \ 184--target spirv-tools-build-version \ 185--target core_tables \ 186--target enum_string_mapping \ 187--target extinst_tables 188echo "Replacing existing .inc and .h files in $ spirv_tools_generated " 189set -x 190rm -f " $ spirv_tools_generated /*.{inc,h}" 191cp --target-directory " $ spirv_tools_generated " " $ build " /*.{inc,h} 192set +x 193 194if [" $ do_commit " ];then 195big_msg "Committing changes" 196msg =$( 197cat << EOF 198external/glslang: ${ old_ref [ "glslang" ]} -> ${ new_ref [ "glslang" ]} 199 200 external/spirv-tools: ${ old_ref [ "spirv-tools" ]} -> ${ new_ref [ "spirv-tools" ]} " 201EOF 202) 203 204git commit \ 205--message " $ msg " \ 206" $ glslang " \ 207" $ glslang_generated " \ 208" $ spirv_headers " \ 209" $ spirv_tools " \ 210" $ spirv_tools_generated " 211 212else 213 214cat <<EOFF 215Commit these changes with: 216msg=\$(cat <<EOF 217external/glslang: ${ old_ref [ "glslang" ]} -> ${ new_ref [ "glslang" ]} 218 219 external/spirv-tools: ${ old_ref [ "spirv-tools" ]} -> ${ new_ref [ "spirv-tools" ]} " 220EOF 221) 222git commit \\ 223--message "\$msg" 224" $ glslang " \\ 225" $ glslang_generated " \\ 226" $ spirv_headers " \\ 227" $ spirv_tools " \\ 228" $ spirv_tools_generated " 229 230EOFF 231 232fi 233 234echo "Please also don't forget to push the new commits in external/glslang and" 235echo "external/spirv-tools to our forks!"