-
Notifications
You must be signed in to change notification settings - Fork 36
/
make_sys.sh
98 lines (81 loc) · 3.96 KB
/
make_sys.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env bash
# NOTE: this script is only intended to be run on CI.
set -xe
export PATH="$HOME/.cargo/bin/":"$PATH"
if [ $# -eq 0 ]; then
LAST_RELEASE=($(curl -s "https://api.github.com/repos/wolfpld/tracy/releases/latest" \
| jq -r '"\(.tag_name)\n\(.tarball_url)"'))
else
LAST_RELEASE=($(curl -s "https://api.github.com/repos/wolfpld/tracy/releases/tags/$1" \
| jq -r '"\(.tag_name)\n\(.tarball_url)"'))
fi
TAG="${LAST_RELEASE[0]}"
TARBALL="${LAST_RELEASE[1]}"
DESTINATION=/tmp/tracy-$TAG # could use mktemp, but unnecessary complexity.
echo "::set-output name=tracy-tag::$TAG"
mkdir -p "$DESTINATION"
curl -sL "$TARBALL" -o - | tar -f - -zxC "$DESTINATION"
BASEDIR=("$DESTINATION"/*)
rm -rf "tracy-client-sys/tracy/"
cp -r "$BASEDIR/public" "tracy-client-sys/tracy"
cp "$BASEDIR/LICENSE" "tracy-client-sys/tracy/"
COMMON_BINDGEN_PARAMS=(
"tracy-client-sys/tracy/tracy/TracyC.h"
"--disable-header-comment"
"--"
"-DTRACY_ENABLE"
)
bindgen -o "tracy-client-sys/src/generated.rs" \
--allowlist-function='.*[Tt][Rr][Aa][Cc][Yy].*' \
--allowlist-type='.*[Tt][Rr][Aa][Cc][Yy].*' \
${COMMON_BINDGEN_PARAMS[@]}
bindgen -o "tracy-client-sys/src/generated_manual_lifetime.rs" \
--allowlist-function='___tracy_startup_profiler' \
--allowlist-function='___tracy_shutdown_profiler' \
${COMMON_BINDGEN_PARAMS[@]} \
-DTRACY_MANUAL_LIFETIME
bindgen -o "tracy-client-sys/src/generated_fibers.rs" \
--allowlist-function='___tracy_fiber_enter' \
--allowlist-function='___tracy_fiber_leave' \
${COMMON_BINDGEN_PARAMS[@]} \
-DTRACY_FIBERS
# The space after type avoids hitting members called "type".
sed -i 's/pub type /type /g' 'tracy-client-sys/src/generated.rs'
# Avoid running the other steps if we haven't really updated tracy (e.g. if bindgen/rustfmt version
# changed)
if ! git diff --quiet "tracy-client-sys/tracy"; then
echo "::set-output name=tracy-changed::true"
else
exit 0
fi
CURRENT_SYS_VERSION=$(sed -n 's/^version = "\(.*\)" # AUTO-BUMP$/\1/p' tracy-client-sys/Cargo.toml)
CURRENT_CLIENT_VERSION=$(sed -n 's/^version = "\(.*\)" # AUTO-BUMP$/\1/p' tracy-client/Cargo.toml)
CURRENT_TRACING_VERSION=$(sed -n 's/^version = "\(.*\)"$/\1/p' tracing-tracy/Cargo.toml)
SYS_MAJOR=$(echo "$CURRENT_SYS_VERSION" | sed -nr 's,([0-9]+)\.[0-9]+\.[0-9]+,\1,p')
SYS_MINOR=$(echo "$CURRENT_SYS_VERSION" | sed -nr 's,[0-9]+\.([0-9]+)\.[0-9]+,\1,p')
NEXT_SYS_MINOR=$(echo "$SYS_MINOR" | awk '{print $0+1}')
NEXTNEXT_SYS_MINOR=$(echo "$NEXT_SYS_MINOR" | awk '{print $0+1}')
SYS_PATCH=$(echo "$CURRENT_SYS_VERSION" | sed -nr 's,[0-9]+\.[0-9]+\.([0-9]+),\1,p')
CLIENT_MAJOR=$(echo "$CURRENT_CLIENT_VERSION" | sed -nr 's,([0-9]+)\.[0-9]+\.[0-9]+,\1,p')
CLIENT_MINOR=$(echo "$CURRENT_CLIENT_VERSION" | sed -nr 's,[0-9]+\.([0-9]+)\.[0-9]+,\1,p')
CLIENT_PATCH=$(echo "$CURRENT_CLIENT_VERSION" | sed -nr 's,[0-9]+\.[0-9]+\.([0-9]+),\1,p')
NEXT_CLIENT_PATCH=$(echo "$CLIENT_PATCH" | awk '{print $0+1}')
NEXT_SYS_VERSION="$SYS_MAJOR.$NEXT_SYS_MINOR.0"
NEXTNEXT_SYS_VERSION="$SYS_MAJOR.$NEXTNEXT_SYS_MINOR.0"
NEXT_CLIENT_VERSION="$CLIENT_MAJOR.$CLIENT_MINOR.$NEXT_CLIENT_PATCH"
# Adjust the table in the README file…
sed -i "/^<!-- AUTO-UPDATE -->$/i $(printf "| %-6s | %-15s | %-12s | %-13s |" "$TAG" "$NEXT_SYS_VERSION" "$NEXT_CLIENT_VERSION" "$CURRENT_TRACING_VERSION")" \
README.mkd
# …the version in tracy-client-sys…
sed -i "s/^\(version =\) \".*\" \(# AUTO-BUMP\)$/\1 \"$NEXT_SYS_VERSION\" \2/" \
tracy-client-sys/Cargo.toml
# …and the versions in tracy-client.
sed -i "s/^\(version =\) \".*\" \(# AUTO-BUMP\)$/\1 \"$NEXT_CLIENT_VERSION\" \2/" \
tracy-client/Cargo.toml
sed -i "s/^\(version = \".*,\) <.*\" \(# AUTO-UPDATE\)$/\1 <$NEXTNEXT_SYS_VERSION\" \2/" \
tracy-client/Cargo.toml
# Make a commit that we'll PR
NAME=tracy-client-sys-auto-update[bot]
MAIL="GitHub <[email protected]>"
git add tracy-client-sys tracy-client/Cargo.toml README.mkd
git -c user.name="$NAME" -c user.email="$MAIL" commit -m "Update Tracy client bindings to $TAG"