authorchloe caruso <git@paperclover.net> 2024-09-20 00:55:26-07:00
committerchloe caruso <git@paperclover.net> 2024-09-20 00:55:26-07:00
log932c12bee896366adcd9d6b667be26d657185372
tree06060fda4e3b14255da3c48f6edb296f58b83526
parenta324b076ea861a6eb10700c19aad40f814d9e687

chore: use local installed zig for formatting


3 files changed, 25 insertions(+), 5 deletions(-)

build+23-4
......@@ -16,6 +16,20 @@ if [ -z "$ZIG_LOCAL_CACHE_DIR" ]; then
1616fi
1717
1818ZIG="$ZIG_LOCAL_CACHE_DIR/zig/$ZIG_VERSION/zig"
19
20if [ "$1" == "--fmt" ]; then
21 # dprint.jsonc is configured to run this, however it runs in parallel.
22 # only one installation should happen, not one per file. since there
23 # is no concise way to acquire a filesystem lock on .zig-cache,
24 # formatting before an install is left unsupported.
25 if [ ! -f "$ZIG" ]; then
26 printf "Zig is not installed. Please run ./build once manually\n"
27 exit 1
28 fi
29 shift
30 exec $ZIG fmt $@
31fi
32
1933if [ ! -f "$ZIG" ]; then
2034 OS=$(uname -s | tr '[:upper:]' '[:lower:]')
2135 if [ "$OS" = "darwin" ]; then
......@@ -28,16 +42,16 @@ if [ ! -f "$ZIG" ]; then
2842
2943 URL="https://ziglang.org/builds/zig-$OS-$ARCH-$ZIG_VERSION.tar.xz"
3044
31 echo "Installing Zig v$ZIG_VERSION via $URL"
45 printf "Installing Zig v$ZIG_VERSION via $URL\n"
3246
3347 CURL=$(command -v curl 2>/dev/null)
3448 TAR=$(command -v curl 2>/dev/null)
3549
3650 if [ -z "$CURL" ]; then
37 echo "This script requires 'curl' to be installed."
51 printf "This script requires 'curl' to be installed.\n"
3852 fi
3953 if [ -z "$TAR" ]; then
40 echo "This script requires 'tar' to be installed."
54 printf "This script requires 'tar' to be installed.\n"
4155 fi
4256
4357 if [ -z "$CURL" ] || [ -z "$TAR" ]; then
......@@ -48,10 +62,15 @@ if [ ! -f "$ZIG" ]; then
4862 curl -fsSL --retry 3 --retry-delay 3 $URL \
4963 | tar -xJ --strip-components=1 -C "$ZIG_LOCAL_CACHE_DIR/zig/$ZIG_VERSION"
5064 if [ "$($ZIG version)" != "$ZIG_VERSION" ]; then
51 echo "Zig failed to install."
65 printf "Zig failed to install.\n"
5266 rm -rf "$ZIG_LOCAL_CACHE_DIR/zig/$ZIG_VERSION"
5367 exit 1
5468 fi
5569fi
5670
71if [ "$1" == "--version" ]; then
72 printf "Zig version: "
73 exec $ZIG version
74fi
75
5776exec $ZIG build $@
ci+1
......@@ -8,6 +8,7 @@ set -e
88commit=$(git rev-parse HEAD)
99commit_short=$(echo "$commit" | cut -c -9)
1010
11./build --version
1112typos
1213dprint check
1314./build all --summary new
dprint.jsonc+1-1
......@@ -18,7 +18,7 @@
1818 "cwd": "${configDir}",
1919 "commands": [
2020 {
21 "command": "zig fmt --stdin",
21 "command": "./build --fmt --stdin",
2222 "exts": ["zig", "zon"],
2323 },
2424 ],