Skip to content

Commit 486b84d

Browse files
committedMar 19, 2025·
Upgrade Zig to version 0.14 and update related configurations. Adjusted build.zig.zon and codecrafters.yml to reflect the new version, modified README.md for installation instructions, and updated run scripts for compatibility. Added Dockerfile for Zig 0.14.
1 parent 138fb54 commit 486b84d

File tree

14 files changed

+48
-18
lines changed

14 files changed

+48
-18
lines changed
 

‎compiled_starters/zig/.codecrafters/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

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

‎compiled_starters/zig/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Time to move on to the next stage!
2929

3030
Note: This section is for stages 2 and beyond.
3131

32-
1. Ensure you have `zig (0.13+)` installed locally
32+
1. Ensure you have `zig (0.14)` installed locally
3333
1. Run `./your_program.sh` to run your program, which is implemented in
3434
`src/main.zig`.
3535
1. Commit your changes and run `git push origin master` to submit your solution

‎compiled_starters/zig/build.zig.zon

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.{
2-
.name = "codecrafters-sqlite",
2+
.name = .codecrafters_sqlite,
3+
.fingerprint = 0x558026c9dcdd8a05,
34

45
// This is a [Semantic Version](https://semver.org/).
56
// In a future version of Zig it will be used for package deduplication.
@@ -8,7 +9,7 @@
89
// This field is optional.
910
// This is currently advisory only; Zig does not yet do anything
1011
// with this value.
11-
//.minimum_zig_version = "0.11.0",
12+
.minimum_zig_version = "0.14.0",
1213

1314
// This field is optional.
1415
// Each dependency must either provide a `url` and `hash`, or a `path`.

‎compiled_starters/zig/codecrafters.yml

+2-2
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.13
11-
language_pack: zig-0.13
10+
# Available versions: zig-0.14
11+
language_pack: zig-0.14

‎compiled_starters/zig/your_program.sh

+1-1
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 zig-out/bin/main "$@"
24+
exec $(dirname $0)/zig-out/bin/main "$@"

‎dockerfiles/zig-0.14.Dockerfile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# syntax=docker/dockerfile:1.7-labs
2+
FROM alpine:3.20
3+
4+
RUN apk add --no-cache 'xz>=5.6' 'curl>=8.9'
5+
6+
# Download and install Zig
7+
RUN curl -O https://ziglang.org/download/0.14.0/zig-linux-x86_64-0.14.0.tar.xz \
8+
&& tar -xf zig-linux-x86_64-0.14.0.tar.xz \
9+
&& mv zig-linux-x86_64-0.14.0 /usr/local/zig \
10+
&& rm zig-linux-x86_64-0.14.0.tar.xz
11+
12+
# Add Zig to PATH
13+
ENV PATH="/usr/local/zig:${PATH}"
14+
15+
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="build.zig,build.zig.zon"
16+
17+
WORKDIR /app
18+
19+
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
20+
COPY --exclude=.git --exclude=README.md . /app
21+
22+
# This runs zig build
23+
RUN .codecrafters/compile.sh
24+
25+
# Cache build directory
26+
RUN mkdir -p /app-cached
27+
RUN mv /app/.zig-cache /app-cached/.zig-cache || true

‎solutions/zig/01-dr6/code/.codecrafters/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

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

‎solutions/zig/01-dr6/code/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Time to move on to the next stage!
2929

3030
Note: This section is for stages 2 and beyond.
3131

32-
1. Ensure you have `zig (0.13+)` installed locally
32+
1. Ensure you have `zig (0.14)` installed locally
3333
1. Run `./your_program.sh` to run your program, which is implemented in
3434
`src/main.zig`.
3535
1. Commit your changes and run `git push origin master` to submit your solution

‎solutions/zig/01-dr6/code/build.zig.zon

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.{
2-
.name = "codecrafters-sqlite",
2+
.name = .codecrafters_sqlite,
3+
.fingerprint = 0x558026c9dcdd8a05,
34

45
// This is a [Semantic Version](https://semver.org/).
56
// In a future version of Zig it will be used for package deduplication.
@@ -8,7 +9,7 @@
89
// This field is optional.
910
// This is currently advisory only; Zig does not yet do anything
1011
// with this value.
11-
//.minimum_zig_version = "0.11.0",
12+
.minimum_zig_version = "0.14.0",
1213

1314
// This field is optional.
1415
// Each dependency must either provide a `url` and `hash`, or a `path`.

‎solutions/zig/01-dr6/code/codecrafters.yml

+2-2
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.13
11-
language_pack: zig-0.13
10+
# Available versions: zig-0.14
11+
language_pack: zig-0.14

‎solutions/zig/01-dr6/code/your_program.sh

+1-1
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 zig-out/bin/main "$@"
24+
exec $(dirname $0)/zig-out/bin/main "$@"

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

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

‎starter_templates/zig/code/build.zig.zon

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.{
2-
.name = "codecrafters-sqlite",
2+
.name = .codecrafters_sqlite,
3+
.fingerprint = 0x558026c9dcdd8a05,
34

45
// This is a [Semantic Version](https://semver.org/).
56
// In a future version of Zig it will be used for package deduplication.
@@ -8,7 +9,7 @@
89
// This field is optional.
910
// This is currently advisory only; Zig does not yet do anything
1011
// with this value.
11-
//.minimum_zig_version = "0.11.0",
12+
.minimum_zig_version = "0.14.0",
1213

1314
// This field is optional.
1415
// Each dependency must either provide a `url` and `hash`, or a `path`.

‎starter_templates/zig/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
attributes:
2-
required_executable: zig (0.13+)
2+
required_executable: zig (0.14)
33
user_editable_file: src/main.zig

0 commit comments

Comments
 (0)