Skip to content

Commit 42ce16f

Browse files
authored
Merge pull request #136 from codecrafters-io/andy/upgrade-zig
Update Zig buildpack to version 0.15 and refactor script execution fo…
2 parents a5eb28b + 927b8d1 commit 42ce16f

File tree

8 files changed

+39
-9
lines changed

8 files changed

+39
-9
lines changed

compiled_starters/zig/.codecrafters/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
exec $(dirname $0)/zig-out/bin/main "$@"
11+
exec "$(dirname "$0")"/zig-out/bin/main "$@"

compiled_starters/zig/codecrafters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ debug: false
77
# Use this to change the Zig version used to run your code
88
# on Codecrafters.
99
#
10-
# Available versions: zig-0.14
11-
buildpack: zig-0.14
10+
# Available versions: zig-0.15
11+
buildpack: zig-0.15

compiled_starters/zig/your_program.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ set -e # Exit early if any commands fail
2121
#
2222
# - Edit this to change how your program runs locally
2323
# - Edit .codecrafters/run.sh to change how your program runs remotely
24-
exec $(dirname $0)/zig-out/bin/main "$@"
24+
exec "$(dirname "$0")"/zig-out/bin/main "$@"

dockerfiles/zig-0.15.Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# syntax=docker/dockerfile:1.7-labs
2+
FROM debian:bookworm
3+
4+
RUN apt-get update && \
5+
apt-get install --no-install-recommends -y xz-utils=5.4.1-1 && \
6+
apt-get clean && \
7+
rm -rf /var/lib/apt/lists/*
8+
9+
# Download and install Zig
10+
RUN curl -O https://ziglang.org/download/0.15.1/zig-x86_64-linux-0.15.1.tar.xz \
11+
&& tar -xf zig-x86_64-linux-0.15.1.tar.xz \
12+
&& mv zig-x86_64-linux-0.15.1 /usr/local/zig \
13+
&& rm zig-x86_64-linux-0.15.1.tar.xz
14+
15+
# Add Zig to PATH
16+
ENV PATH="/usr/local/zig:${PATH}"
17+
18+
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="build.zig,build.zig.zon"
19+
20+
WORKDIR /app
21+
22+
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
23+
COPY --exclude=.git --exclude=README.md . /app
24+
25+
# This runs zig build
26+
RUN .codecrafters/compile.sh
27+
28+
# Cache build directory
29+
RUN mkdir -p /app-cached
30+
RUN mv /app/.zig-cache /app-cached/.zig-cache || true

solutions/zig/01-at4/code/.codecrafters/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
exec $(dirname $0)/zig-out/bin/main "$@"
11+
exec "$(dirname "$0")"/zig-out/bin/main "$@"

solutions/zig/01-at4/code/codecrafters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ debug: false
77
# Use this to change the Zig version used to run your code
88
# on Codecrafters.
99
#
10-
# Available versions: zig-0.14
11-
buildpack: zig-0.14
10+
# Available versions: zig-0.15
11+
buildpack: zig-0.15

solutions/zig/01-at4/code/your_program.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ set -e # Exit early if any commands fail
2121
#
2222
# - Edit this to change how your program runs locally
2323
# - Edit .codecrafters/run.sh to change how your program runs remotely
24-
exec $(dirname $0)/zig-out/bin/main "$@"
24+
exec "$(dirname "$0")"/zig-out/bin/main "$@"

starter_templates/zig/code/.codecrafters/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
exec $(dirname $0)/zig-out/bin/main "$@"
11+
exec "$(dirname "$0")"/zig-out/bin/main "$@"

0 commit comments

Comments
 (0)