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

add zigup for easier zig toolchain installation #6

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"