Add zig version helper script
This commit is contained in:
parent
837a437575
commit
acec3e78ab
2 changed files with 38 additions and 0 deletions
1
build.zig.version
Normal file
1
build.zig.version
Normal file
|
@ -0,0 +1 @@
|
|||
0.12.0-dev.2817+7461309b7
|
37
zig
Executable file
37
zig
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
ARCH=$(uname -m)
|
||||
|
||||
BASEDIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
ZIGDIR=$BASEDIR/.cache/zig
|
||||
VERSION=$(< build.zig.version)
|
||||
ZIGVER="zig-linux-$ARCH-$VERSION"
|
||||
ZIG=$ZIGDIR/$ZIGVER/zig
|
||||
|
||||
if [ "$1" == "update" ] ; then
|
||||
curl -L --silent https://ziglang.org/download/index.json | jq -r '.master | .version' > build.zig.version
|
||||
NEWVERSION=$(< build.zig.version)
|
||||
|
||||
if [ "$VERSION" != "$NEWVERSION" ] ; then
|
||||
echo zig version updated from $VERSION to $NEWVERSION
|
||||
exit 0
|
||||
fi
|
||||
echo zig version $VERSION is up-to-date
|
||||
exit 0
|
||||
fi
|
||||
|
||||
get_zig() {
|
||||
(
|
||||
mkdir -p "$ZIGDIR"
|
||||
cd "$ZIGDIR"
|
||||
TARBALL="https://ziglang.org/builds/$ZIGVER.tar.xz"
|
||||
|
||||
if [ ! -d "$ZIGVER" ] ; then
|
||||
curl "$TARBALL" | tar -xJ
|
||||
fi
|
||||
)
|
||||
}
|
||||
get_zig
|
||||
|
||||
exec $ZIG "$@"
|
Loading…
Add table
Add a link
Reference in a new issue