Skip to content

Commit

Permalink
Update to Zig 0.13
Browse files Browse the repository at this point in the history
Add docker ignore file
Add auto-update to building of examples
  • Loading branch information
fkollmann committed Jun 11, 2024
1 parent ed91cf2 commit 7db33e0
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
./.git/
./.zig-cache/
./.github/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.zig-cache/
zig-cache/
zig-out/

Expand Down
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});

_ = b.addModule("zzmq", .{
.root_source_file = .{ .path = "src/zzmq.zig" },
.root_source_file = b.path("src/zzmq.zig"),
});

const lib_test = b.addTest(.{
.root_source_file = .{ .path = "src/zzmq.zig" },
.root_source_file = b.path("src/zzmq.zig"),
.target = target,
.optimize = optimize,
});
Expand Down
7 changes: 7 additions & 0 deletions build_all_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

set -e

if [ -z "$ZIG_VERSION" ]; then
ZIG_VERSION="$(zig version | sed -E 's/^([0-9]+\.[0-9]+)\.[0-9]+$/\1/')"
fi

echo "Zig version: $ZIG_VERSION"

for x in ./examples/*/build.zig; do
EXAMPLEDIR=$(dirname "$x")

echo "Building example: $EXAMPLEDIR ..."

pushd $EXAMPLEDIR > /dev/null

zig fetch --save=zzmq "https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig${ZIG_VERSION}.tar.gz"
zig build

popd > /dev/null
Expand Down
18 changes: 14 additions & 4 deletions examples.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
FROM alpine:3.19 as builder
FROM alpine:3.20 as zig

# install Zig 0.12 from Alpine edge community repo: https://pkgs.alpinelinux.org/package/edge/community/x86_64/zig
ARG ZIG_VERSION=0.13

# install Zig 0.13 from Alpine edge community repo: https://pkgs.alpinelinux.org/package/edge/community/x86_64/zig
RUN echo "@edge-community https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add --no-cache zig@edge-community~=0.12.0
RUN echo "@edge-main https://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories

RUN apk add --no-cache zig@edge-community~=${ZIG_VERSION}.0 clang18@edge-main lld-libs@edge-main



FROM zig as builder

# install dependencies
RUN apk add --no-cache zeromq-dev clang bash
RUN apk add --no-cache bash zeromq-dev



COPY . /build/

Expand Down
4 changes: 2 additions & 2 deletions examples/dealer_rep_client/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn build(b: *std.Build) void {
.name = "dealer_rep_client",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down Expand Up @@ -65,7 +65,7 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down
4 changes: 2 additions & 2 deletions examples/dealer_rep_client/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

.dependencies = .{
.zzmq = .{
.url = "https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig0.12.tar.gz",
.hash = "122048ba004ea870098285b895c9f9dfefe33027d0982c7df0efe2a07bb6040cebea",
.url = "https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig0.13.tar.gz",
.hash = "12203b274a2bf7cef4a6aa59fa30b65050eb292d6421a7ff14ec7b0c8d299c7a5f2f",
},
},
}
4 changes: 2 additions & 2 deletions examples/dealer_rep_server/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn build(b: *std.Build) void {
.name = "dealer_rep_server",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down Expand Up @@ -65,7 +65,7 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down
4 changes: 2 additions & 2 deletions examples/dealer_rep_server/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

.dependencies = .{
.zzmq = .{
.url = "https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig0.12.tar.gz",
.hash = "122048ba004ea870098285b895c9f9dfefe33027d0982c7df0efe2a07bb6040cebea",
.url = "https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig0.13.tar.gz",
.hash = "12203b274a2bf7cef4a6aa59fa30b65050eb292d6421a7ff14ec7b0c8d299c7a5f2f",
},
},
}
4 changes: 2 additions & 2 deletions examples/hello_world_client/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn build(b: *std.Build) void {
.name = "hello_world_client",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down Expand Up @@ -65,7 +65,7 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down
4 changes: 2 additions & 2 deletions examples/hello_world_client/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

.dependencies = .{
.zzmq = .{
.url = "https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig0.12.tar.gz",
.hash = "122048ba004ea870098285b895c9f9dfefe33027d0982c7df0efe2a07bb6040cebea",
.url = "https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig0.13.tar.gz",
.hash = "12203b274a2bf7cef4a6aa59fa30b65050eb292d6421a7ff14ec7b0c8d299c7a5f2f",
},
},
}
4 changes: 2 additions & 2 deletions examples/hello_world_server/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn build(b: *std.Build) void {
.name = "hello_world_server",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down Expand Up @@ -65,7 +65,7 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down
4 changes: 2 additions & 2 deletions examples/hello_world_server/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

.dependencies = .{
.zzmq = .{
.url = "https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig0.12.tar.gz",
.hash = "122048ba004ea870098285b895c9f9dfefe33027d0982c7df0efe2a07bb6040cebea",
.url = "https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig0.13.tar.gz",
.hash = "12203b274a2bf7cef4a6aa59fa30b65050eb292d6421a7ff14ec7b0c8d299c7a5f2f",
},
},
}
18 changes: 14 additions & 4 deletions test.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
FROM alpine:3.19 as builder
FROM alpine:3.20 as zig

# install Zig 0.12 from Alpine edge community repo: https://pkgs.alpinelinux.org/package/edge/community/x86_64/zig
ARG ZIG_VERSION=0.13

# install Zig 0.13 from Alpine edge community repo: https://pkgs.alpinelinux.org/package/edge/community/x86_64/zig
RUN echo "@edge-community https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add --no-cache zig@edge-community~=0.12.0
RUN echo "@edge-main https://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories

RUN apk add --no-cache zig@edge-community~=${ZIG_VERSION}.0 clang18@edge-main lld-libs@edge-main



FROM zig as builder

# install dependencies
RUN apk add --no-cache zeromq-dev clang
RUN apk add --no-cache zeromq-dev



COPY . /build/

Expand Down

0 comments on commit 7db33e0

Please sign in to comment.