Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e4e829f

Browse files
authoredMar 1, 2024··
add zigup for easier zig toolchain installation (#6)
1 parent 8587a3d commit e4e829f

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
 

‎.zig-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.12.0-dev.2541+894493549

‎README.md

+6
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ The header file requires `zig.h` which is located in the `lib_dir` output by run
166166

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

169+
## Installing Zig
170+
171+
Running `./zigup` will download and install the zig version specified in the `.zig-version` file. We recommend adding
172+
`$HOME/.zig/zig-latest` to your `PATH`.
173+
174+
169175
## Python Library
170176

171177
TODO: this library will be made available as a Python library using [Ziggy Pydust](https://github.com/fulcrum-so/ziggy-pydust).

‎zigup

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
ZIG_HOME="${ZIG_HOME:-$HOME/.zig}"
6+
ZIG_LATEST="${ZIG_HOME}/zig-latest"
7+
mkdir -p "$ZIG_HOME"
8+
9+
VERSION=$(cat ".zig-version" | tr -d '\n ')
10+
11+
osOut="$(uname -s)"
12+
case "${osOut}" in
13+
Linux*) OS="linux";;
14+
Darwin*) OS="macos";;
15+
esac
16+
17+
archOut="$(uname -m)"
18+
case "${archOut}" in
19+
arm64*) ARCH="aarch64";;
20+
x86_64*) ARCH="x86_64";;
21+
esac
22+
23+
ARCH_VERSION="zig-${OS}-${ARCH}-${VERSION}"
24+
25+
if [ ! -d "${ZIG_HOME}/${ARCH_VERSION}" ]
26+
then
27+
echo "Downloading Zig version $VERSION"
28+
curl -s -L "https://ziglang.org/builds/${ARCH_VERSION}.tar.xz" | tar -x -J -C "${ZIG_HOME}"
29+
else
30+
echo "Zig version $VERSION already installed"
31+
fi
32+
33+
# Always update the symlink to the requested version
34+
rm -f "$ZIG_LATEST"
35+
ln -s "${ZIG_HOME}/${ARCH_VERSION}" "$ZIG_LATEST"
36+
37+
echo "Add ${ZIG_LATEST} to the \$PATH"

0 commit comments

Comments
 (0)
This repository has been archived.