Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update zig #259

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiled_starters/zig/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

set -e # Exit on failure

exec zig-out/bin/zig "$@"
exec zig-out/bin/main "$@"
1 change: 1 addition & 0 deletions compiled_starters/zig/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Zig build artifacts
main
zig-cache/
.zig-cache/
zig-out/

# Compiled binary output
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/zig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ That's all!

Note: This section is for stages 2 and beyond.

1. Ensure you have `zig (0.12)` installed locally
1. Ensure you have `zig (0.13+)` installed locally
1. Run `./your_program.sh` to run your Redis server, which is implemented in
`src/main.zig`.
1. Commit your changes and run `git push origin master` to submit your solution
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const std = @import("std");
// Learn more about this file here: https://ziglang.org/learn/build-system
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "zig",
.name = "main",
.root_source_file = b.path("src/main.zig"),
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
Expand Down
3 changes: 2 additions & 1 deletion compiled_starters/zig/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.{
.name = "zig",
.name = "codecrafters-redis",

// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.0.0",
Expand Down
4 changes: 2 additions & 2 deletions compiled_starters/zig/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the Zig version used to run your code
# on Codecrafters.
#
# Available versions: zig-0.12
language_pack: zig-0.12
# Available versions: zig-0.13
language_pack: zig-0.13
2 changes: 1 addition & 1 deletion compiled_starters/zig/your_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ set -e # Exit early if any commands fail
#
# - Edit this to change how your program runs locally
# - Edit .codecrafters/run.sh to change how your program runs remotely
exec zig-out/bin/zig "$@"
exec zig-out/bin/main "$@"
27 changes: 27 additions & 0 deletions dockerfiles/zig-0.13.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# syntax=docker/dockerfile:1.7-labs
FROM alpine:3.20

RUN apk add --no-cache 'xz>=5.6' 'curl>=8.9'

# Download and install Zig
RUN curl -O https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz \
&& tar -xf zig-linux-x86_64-0.13.0.tar.xz \
&& mv zig-linux-x86_64-0.13.0 /usr/local/zig \
&& rm zig-linux-x86_64-0.13.0.tar.xz

# Add Zig to PATH
ENV PATH="/usr/local/zig:${PATH}"

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="build.zig,build.zig.zon"

WORKDIR /app

# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app

# This runs zig build
RUN .codecrafters/compile.sh

# Cache build directory
RUN mkdir -p /app-cached
RUN mv /app/.zig-cache /app-cached/.zig-cache || true
2 changes: 1 addition & 1 deletion solutions/zig/01-jm1/code/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

set -e # Exit on failure

exec zig-out/bin/zig "$@"
exec zig-out/bin/main "$@"
1 change: 1 addition & 0 deletions solutions/zig/01-jm1/code/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Zig build artifacts
main
zig-cache/
.zig-cache/
zig-out/

# Compiled binary output
Expand Down
2 changes: 1 addition & 1 deletion solutions/zig/01-jm1/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ That's all!

Note: This section is for stages 2 and beyond.

1. Ensure you have `zig (0.12)` installed locally
1. Ensure you have `zig (0.13+)` installed locally
1. Run `./your_program.sh` to run your Redis server, which is implemented in
`src/main.zig`.
1. Commit your changes and run `git push origin master` to submit your solution
Expand Down
2 changes: 1 addition & 1 deletion solutions/zig/01-jm1/code/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const std = @import("std");
// Learn more about this file here: https://ziglang.org/learn/build-system
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "zig",
.name = "main",
.root_source_file = b.path("src/main.zig"),
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
Expand Down
3 changes: 2 additions & 1 deletion solutions/zig/01-jm1/code/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.{
.name = "zig",
.name = "codecrafters-redis",

// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.0.0",
Expand Down
4 changes: 2 additions & 2 deletions solutions/zig/01-jm1/code/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the Zig version used to run your code
# on Codecrafters.
#
# Available versions: zig-0.12
language_pack: zig-0.12
# Available versions: zig-0.13
language_pack: zig-0.13
2 changes: 1 addition & 1 deletion solutions/zig/01-jm1/code/your_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ set -e # Exit early if any commands fail
#
# - Edit this to change how your program runs locally
# - Edit .codecrafters/run.sh to change how your program runs remotely
exec zig-out/bin/zig "$@"
exec zig-out/bin/main "$@"
2 changes: 1 addition & 1 deletion starter_templates/zig/code/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

set -e # Exit on failure

exec zig-out/bin/zig "$@"
exec zig-out/bin/main "$@"
1 change: 1 addition & 0 deletions starter_templates/zig/code/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Zig build artifacts
main
zig-cache/
.zig-cache/
zig-out/

# Compiled binary output
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/zig/code/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const std = @import("std");
// Learn more about this file here: https://ziglang.org/learn/build-system
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "zig",
.name = "main",
.root_source_file = b.path("src/main.zig"),
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
Expand Down
3 changes: 2 additions & 1 deletion starter_templates/zig/code/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.{
.name = "zig",
.name = "codecrafters-redis",

// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/zig/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
attributes:
required_executable: zig (0.12)
required_executable: zig (0.13+)
user_editable_file: src/main.zig
Loading