forked from shader-slang/slang-glslang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-and-sync.sh
executable file
·78 lines (63 loc) · 1.65 KB
/
update-and-sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
set -e
while [[ "$#" -gt 0 ]]; do
case $1 in
-h | --help) help=1 ;;
*)
echo "Unknown parameter passed: $1" >&2
exit 1
;;
esac
shift
done
if [ $help ]; then
me=$(basename "$0")
cat <<EOF
$me: Update external/slang and synchronize submodules
- Pull the latest changes into external/slang
- Make the other submodules in "external" point to the same commits as their
counterpart submodules in "external/slang/external"
- Commit the changes to git if there were changes
EOF
exit
fi
dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)
external=$dir/external
slang=$external/slang
paths=()
tmp="$(mktemp -d)"
trap 'rm -rf -- "$tmp"' EXIT
msg=$tmp/msg
git submodule update --init
describe(){
git -C "$1" describe --always --exclude master-tot --tags
}
git -C "$slang" fetch --tags --force
old_ref=$(describe "$slang")
git submodule update --remote --checkout "$slang"
git -C "$slang" submodule update --init --recursive
new_ref=$(describe "$slang")
if [ "$old_ref" != "$new_ref" ]; then
paths+=("$slang")
echo "${slang#"$dir/"}: $old_ref -> $new_ref" >> "$msg"
echo >> "$msg"
fi
sync(){
echo "Sync $1"
git -C "$external/$1" fetch --tags --force
old_ref=$(describe "$external/$1")
ref=$(git -C "$slang" submodule status -- "$slang/external/$1" | cut -d' ' -f2)
git -C "$external/$1" checkout "$ref"
new_ref=$(describe "$external/$1")
if [ "$old_ref" != "$new_ref" ]; then
paths+=("$external/$1")
echo "- external/$1: $old_ref -> $new_ref" >> "$msg"
fi
}
sync glslang
sync spirv-tools
sync spirv-headers
sync slang-binaries
if [ -f "$msg" ]; then
git commit --file "$msg" "${paths[@]}"
fi