From c7821d9bcc2efb3fd1b392c680d1b62f6687aaf4 Mon Sep 17 00:00:00 2001 From: cryptocode Date: Sun, 30 Jun 2024 00:16:40 +0200 Subject: [PATCH] Upgrade to latest Zig master --- README.md | 3 ++- build.zig | 6 +++--- src/lib.zig | 4 ++-- src/main.zig | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7434346..5232cf5 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ Resoures can be anything, such as scripts, images, text, templates config files * An image in your own format that's able to display itself when executed ## Building the project -*Last tested with Zig version 0.12.0-dev.3161+377ecc6af* +To build with Zig 0.13, use the `zig-` tag/release. +To build with Zig master, use the main branch (last tested with Zig 0.14.0-dev.130+cb308ba3a) `zig build` will put a `bin` and `lib` directory in your output folder (e.g. zig-out) diff --git a/build.zig b/build.zig index 6a174ad..c8ea33b 100644 --- a/build.zig +++ b/build.zig @@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void { const lib = b.addStaticLibrary(.{ .name = "stitch", - .root_source_file = .{ .path = "src/lib.zig" }, + .root_source_file = b.path("src/lib.zig"), .target = target, .optimize = optimize, }); @@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "stitch", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); @@ -34,7 +34,7 @@ pub fn build(b: *std.Build) void { // Creates a step for unit testing. const main_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/tests.zig" }, + .root_source_file = b.path("src/tests.zig"), .target = target, .optimize = optimize, }); diff --git a/src/lib.zig b/src/lib.zig index 88795ed..dd194a5 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -686,9 +686,9 @@ pub fn testTeardown() void { // Create a cryptographically unique filename; mostly useful for test purposes pub fn generateUniqueFileName(allocator: std.mem.Allocator) ![]const u8 { var output: [16]u8 = undefined; - var secret_seed: [std.rand.DefaultCsprng.secret_seed_length]u8 = undefined; + var secret_seed: [std.Random.DefaultCsprng.secret_seed_length]u8 = undefined; std.crypto.random.bytes(&secret_seed); - var csprng = std.rand.DefaultCsprng.init(secret_seed); + var csprng = std.Random.DefaultCsprng.init(secret_seed); const random = csprng.random(); random.bytes(&output); diff --git a/src/main.zig b/src/main.zig index bcbd088..ef92ec5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -111,7 +111,7 @@ pub const Cmdline = struct { } } else { // The filename is stored in the index, so it can be found by name. By using name=path, an alternative name can be given - var it = std.mem.split(u8, arg, "="); + var it = std.mem.splitScalar(u8, arg, '='); var name = it.next(); const second = it.next(); const path = if (second != null) second.? else name.?;