diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..85843c7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +./.git/ +./.zig-cache/ +./.github/ diff --git a/.gitignore b/.gitignore index 81d3664..784c70c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.zig-cache/ zig-cache/ zig-out/ diff --git a/build.zig b/build.zig index 58a3337..ab247e3 100644 --- a/build.zig +++ b/build.zig @@ -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, }); diff --git a/build_all_examples.sh b/build_all_examples.sh index bb50e30..b910754 100755 --- a/build_all_examples.sh +++ b/build_all_examples.sh @@ -2,6 +2,12 @@ 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") @@ -9,6 +15,7 @@ for x in ./examples/*/build.zig; do 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 diff --git a/examples.Dockerfile b/examples.Dockerfile index 7f7f19e..39a92c9 100644 --- a/examples.Dockerfile +++ b/examples.Dockerfile @@ -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/ diff --git a/examples/dealer_rep_client/build.zig b/examples/dealer_rep_client/build.zig index 20ea80a..e1818ad 100644 --- a/examples/dealer_rep_client/build.zig +++ b/examples/dealer_rep_client/build.zig @@ -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, }); @@ -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, }); diff --git a/examples/dealer_rep_client/build.zig.zon b/examples/dealer_rep_client/build.zig.zon index 6335730..a6e690c 100644 --- a/examples/dealer_rep_client/build.zig.zon +++ b/examples/dealer_rep_client/build.zig.zon @@ -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", }, }, } diff --git a/examples/dealer_rep_server/build.zig b/examples/dealer_rep_server/build.zig index 16e5122..295b475 100644 --- a/examples/dealer_rep_server/build.zig +++ b/examples/dealer_rep_server/build.zig @@ -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, }); @@ -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, }); diff --git a/examples/dealer_rep_server/build.zig.zon b/examples/dealer_rep_server/build.zig.zon index 9b27a83..5a24524 100644 --- a/examples/dealer_rep_server/build.zig.zon +++ b/examples/dealer_rep_server/build.zig.zon @@ -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", }, }, } diff --git a/examples/hello_world_client/build.zig b/examples/hello_world_client/build.zig index 7284716..9c03021 100644 --- a/examples/hello_world_client/build.zig +++ b/examples/hello_world_client/build.zig @@ -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, }); @@ -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, }); diff --git a/examples/hello_world_client/build.zig.zon b/examples/hello_world_client/build.zig.zon index 5d00313..d54a15c 100644 --- a/examples/hello_world_client/build.zig.zon +++ b/examples/hello_world_client/build.zig.zon @@ -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", }, }, } diff --git a/examples/hello_world_server/build.zig b/examples/hello_world_server/build.zig index bc00088..9609e11 100644 --- a/examples/hello_world_server/build.zig +++ b/examples/hello_world_server/build.zig @@ -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, }); @@ -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, }); diff --git a/examples/hello_world_server/build.zig.zon b/examples/hello_world_server/build.zig.zon index 999fbf3..720a123 100644 --- a/examples/hello_world_server/build.zig.zon +++ b/examples/hello_world_server/build.zig.zon @@ -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", }, }, } diff --git a/test.Dockerfile b/test.Dockerfile index 028afde..8faf843 100644 --- a/test.Dockerfile +++ b/test.Dockerfile @@ -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/