fix: update zig wrapper script
This commit is contained in:
parent
1691421a94
commit
1da74bfb5c
1 changed files with 30 additions and 19 deletions
25
zig
25
zig
|
@ -13,8 +13,16 @@ if [ "$OS" == "Linux" ] ; then
|
||||||
OS=linux
|
OS=linux
|
||||||
elif [ "$OS" == "Darwin" ]; then
|
elif [ "$OS" == "Darwin" ]; then
|
||||||
OS=macos
|
OS=macos
|
||||||
|
elif [ "$OS" == "FreeBSD" ]; then
|
||||||
|
OS=freebsd
|
||||||
|
if [ "$ARCH" == "amd64" ]; then
|
||||||
|
ARCH=x86_64
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$ARCH" == "arm64" ]; then
|
||||||
|
ARCH=aarch64
|
||||||
|
fi
|
||||||
|
|
||||||
ZIGVER="zig-$OS-$ARCH-$VERSION"
|
ZIGVER="zig-$OS-$ARCH-$VERSION"
|
||||||
ZIG=$ZIGDIR/$ZIGVER/zig
|
ZIG=$ZIGDIR/$ZIGVER/zig
|
||||||
|
@ -24,12 +32,12 @@ if [ "$1" == "update" ] ; then
|
||||||
NEWVERSION=$(<build.zig.version)
|
NEWVERSION=$(<build.zig.version)
|
||||||
|
|
||||||
if [ "$VERSION" != "$NEWVERSION" ]; then
|
if [ "$VERSION" != "$NEWVERSION" ]; then
|
||||||
echo zig version updated from $VERSION to $NEWVERSION
|
echo "zig version updated from $VERSION to $NEWVERSION"
|
||||||
echo rebuilding to update cdb...
|
echo "rebuilding to update cdb..."
|
||||||
$0 cdb
|
$0 cdb
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo zig version $VERSION is up-to-date
|
echo "zig version $VERSION is up-to-date"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -37,7 +45,7 @@ get_zig() {
|
||||||
(
|
(
|
||||||
mkdir -p "$ZIGDIR"
|
mkdir -p "$ZIGDIR"
|
||||||
cd "$ZIGDIR"
|
cd "$ZIGDIR"
|
||||||
TARBALL="https://ziglang.org/builds/$ZIGVER.tar.xz"
|
TARBALL="https://ziglang.org/download/$VERSION/$ZIGVER.tar.xz"
|
||||||
|
|
||||||
if [ ! -d "$ZIGVER" ]; then
|
if [ ! -d "$ZIGVER" ]; then
|
||||||
curl "$TARBALL" | tar -xJ
|
curl "$TARBALL" | tar -xJ
|
||||||
|
@ -47,13 +55,16 @@ get_zig() {
|
||||||
get_zig
|
get_zig
|
||||||
|
|
||||||
if [ "$1" == "cdb" ]; then
|
if [ "$1" == "cdb" ]; then
|
||||||
shift
|
|
||||||
rm -rf .zig-cache
|
rm -rf .zig-cache
|
||||||
rm -rf .cache/cdb
|
rm -rf .cache/cdb
|
||||||
|
|
||||||
$ZIG build "$@"
|
$ZIG build
|
||||||
|
|
||||||
(echo \[ ; cat .cache/cdb/* ; echo {}\]) | perl -0777 -pe 's/,\n\{\}//igs' | jq . | grep -v 'no-default-config' > compile_commands.json
|
(
|
||||||
|
echo \[
|
||||||
|
cat .cache/cdb/*
|
||||||
|
echo {}\]
|
||||||
|
) | perl -0777 -pe 's/,\n\{\}//igs' | jq . | grep -v 'no-default-config' >compile_commands.json
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue