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...@@ -16,6 +16,20 @@ if [ -z "$ZIG_LOCAL_CACHE_DIR" ]; then
16fi16fi
1717
18ZIG="$ZIG_LOCAL_CACHE_DIR/zig/$ZIG_VERSION/zig"18ZIG="$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
19if [ ! -f "$ZIG" ]; then33if [ ! -f "$ZIG" ]; then
20 OS=$(uname -s | tr '[:upper:]' '[:lower:]')34 OS=$(uname -s | tr '[:upper:]' '[:lower:]')
21 if [ "$OS" = "darwin" ]; then35 if [ "$OS" = "darwin" ]; then
...@@ -28,16 +42,16 @@ if [ ! -f "$ZIG" ]; then...@@ -28,16 +42,16 @@ if [ ! -f "$ZIG" ]; then
2842
29 URL="https://ziglang.org/builds/zig-$OS-$ARCH-$ZIG_VERSION.tar.xz"43 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
33 CURL=$(command -v curl 2>/dev/null)47 CURL=$(command -v curl 2>/dev/null)
34 TAR=$(command -v curl 2>/dev/null)48 TAR=$(command -v curl 2>/dev/null)
3549
36 if [ -z "$CURL" ]; then50 if [ -z "$CURL" ]; then
37 echo "This script requires 'curl' to be installed."51 printf "This script requires 'curl' to be installed.\n"
38 fi52 fi
39 if [ -z "$TAR" ]; then53 if [ -z "$TAR" ]; then
40 echo "This script requires 'tar' to be installed."54 printf "This script requires 'tar' to be installed.\n"
41 fi55 fi
4256
43 if [ -z "$CURL" ] || [ -z "$TAR" ]; then57 if [ -z "$CURL" ] || [ -z "$TAR" ]; then
...@@ -48,10 +62,15 @@ if [ ! -f "$ZIG" ]; then...@@ -48,10 +62,15 @@ if [ ! -f "$ZIG" ]; then
48 curl -fsSL --retry 3 --retry-delay 3 $URL \62 curl -fsSL --retry 3 --retry-delay 3 $URL \
49 | tar -xJ --strip-components=1 -C "$ZIG_LOCAL_CACHE_DIR/zig/$ZIG_VERSION"63 | tar -xJ --strip-components=1 -C "$ZIG_LOCAL_CACHE_DIR/zig/$ZIG_VERSION"
50 if [ "$($ZIG version)" != "$ZIG_VERSION" ]; then64 if [ "$($ZIG version)" != "$ZIG_VERSION" ]; then
51 echo "Zig failed to install."65 printf "Zig failed to install.\n"
52 rm -rf "$ZIG_LOCAL_CACHE_DIR/zig/$ZIG_VERSION"66 rm -rf "$ZIG_LOCAL_CACHE_DIR/zig/$ZIG_VERSION"
53 exit 167 exit 1
54 fi68 fi
55fi69fi
5670
71if [ "$1" == "--version" ]; then
72 printf "Zig version: "
73 exec $ZIG version
74fi
75
57exec $ZIG build $@76exec $ZIG build $@
ci+1
...@@ -8,6 +8,7 @@ set -e...@@ -8,6 +8,7 @@ set -e
8commit=$(git rev-parse HEAD)8commit=$(git rev-parse HEAD)
9commit_short=$(echo "$commit" | cut -c -9)9commit_short=$(echo "$commit" | cut -c -9)
1010
11./build --version
11typos12typos
12dprint check13dprint check
13./build all --summary new14./build all --summary new
dprint.jsonc+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18 "cwd": "${configDir}",18 "cwd": "${configDir}",
19 "commands": [19 "commands": [
20 {20 {
21 "command": "zig fmt --stdin",21 "command": "./build --fmt --stdin",
22 "exts": ["zig", "zon"],22 "exts": ["zig", "zon"],
23 },23 },
24 ],24 ],