Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
add zigup for easier zig toolchain installation (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwwmanning authored Mar 1, 2024
1 parent 8587a3d commit e4e829f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions .zig-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.12.0-dev.2541+894493549
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ The header file requires `zig.h` which is located in the `lib_dir` output by run

This process should improve as https://github.com/ziglang/zig/issues/13528 is resolved.

## Installing Zig

Running `./zigup` will download and install the zig version specified in the `.zig-version` file. We recommend adding
`$HOME/.zig/zig-latest` to your `PATH`.


## Python Library

TODO: this library will be made available as a Python library using [Ziggy Pydust](https://github.com/fulcrum-so/ziggy-pydust).
Expand Down
37 changes: 37 additions & 0 deletions zigup
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -euo pipefail

ZIG_HOME="${ZIG_HOME:-$HOME/.zig}"
ZIG_LATEST="${ZIG_HOME}/zig-latest"
mkdir -p "$ZIG_HOME"

VERSION=$(cat ".zig-version" | tr -d '\n ')

osOut="$(uname -s)"
case "${osOut}" in
Linux*) OS="linux";;
Darwin*) OS="macos";;
esac

archOut="$(uname -m)"
case "${archOut}" in
arm64*) ARCH="aarch64";;
x86_64*) ARCH="x86_64";;
esac

ARCH_VERSION="zig-${OS}-${ARCH}-${VERSION}"

if [ ! -d "${ZIG_HOME}/${ARCH_VERSION}" ]
then
echo "Downloading Zig version $VERSION"
curl -s -L "https://ziglang.org/builds/${ARCH_VERSION}.tar.xz" | tar -x -J -C "${ZIG_HOME}"
else
echo "Zig version $VERSION already installed"
fi

# Always update the symlink to the requested version
rm -f "$ZIG_LATEST"
ln -s "${ZIG_HOME}/${ARCH_VERSION}" "$ZIG_LATEST"

echo "Add ${ZIG_LATEST} to the \$PATH"

0 comments on commit e4e829f

Please sign in to comment.