From e5c1d4d2b7ff4c2f1876ca40bd79ba2c06b38a5d Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Thu, 14 Dec 2023 21:25:12 -0600 Subject: [PATCH] feat: update dependency for zig v0.11.0 --- build.zig | 34 +++++++++++++++++++++++++++++----- build.zig.zon | 4 ++-- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/build.zig b/build.zig index cde8047..7523958 100644 --- a/build.zig +++ b/build.zig @@ -1,16 +1,40 @@ const std = @import("std"); +// Although this function looks imperative, note that its job is to +// declaratively construct a build graph that will be executed by an external +// runner. pub fn build(b: *std.Build) void { + // Standard target options allows the person running `zig build` to choose + // what target to build for. Here we do not override the defaults, which + // means any target is allowed, and the default is native. Other options + // for restricting supported target set are available. const target = b.standardTargetOptions(.{}); - const net_dep = b.dependency("zig-network", .{}); // https://github.com/MasterQ32/zig-network + + // Standard optimization options allow the person running `zig build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not + // set a preferred release mode, allowing the user to decide how to optimize. + const optimize = b.standardOptimizeOption(.{}); + + const zig_network = b.dependency("zig-network", .{}); // https://github.com/MasterQ32/zig-network _ = b.addModule("gdbstub", .{ .source_file = .{ .path = "src/lib.zig" }, - .dependencies = &.{.{ .name = "network", .module = net_dep.module("network") }}, + .dependencies = &.{.{ .name = "network", .module = zig_network.module("network") }}, }); - const lib_test = b.addTest(.{ .root_source_file = .{ .path = "src/lib.zig" }, .target = target }); + // Creates a step for unit testing. This only builds the test executable + // but does not run it. + const lib_tests = b.addTest(.{ + .root_source_file = .{ .path = "src/lib.zig" }, + .target = target, + .optimize = optimize, + }); - const test_step = b.step("test", "Run Library Tests"); - test_step.dependOn(&lib_test.step); + const run_lib_tests = b.addRunArtifact(lib_tests); + + // This creates a build step. It will be visible in the `zig build --help` menu, + // and can be selected like this: `zig build test` + // This will evaluate the `test` step rather than the default, which is "install". + const test_step = b.step("test", "Run library tests"); + test_step.dependOn(&run_lib_tests.step); } diff --git a/build.zig.zon b/build.zig.zon index 3d826c6..7a28d4e 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,8 +3,8 @@ .version = "0.1.0", .dependencies = .{ .@"zig-network" = .{ - .url = "https://github.com/MasterQ32/zig-network/archive/7b5f76ea09626b96755c027bf4bd5b7e45297027.tar.gz", - .hash = "122090e7cb4459c2224399a45c56f47462733b919aa547c96b8c14ee705bfa22976e", + .url = "https://github.com/MasterQ32/zig-network/archive/07ef40cacd7b00bc0f26e254d97d4d4c9071195a.tar.gz", + .hash = "12204d3d4c1184d379a78399e5ddd8a46fe19ca6c991d5c9b909c1980d14acb1dede", }, }, }