build: update to Zig 0.15

This commit is contained in:
Isaac Freund
2025-07-11 18:08:50 +02:00
parent 63542fdf3e
commit d72408df18
37 changed files with 323 additions and 274 deletions

View File

@ -16,7 +16,7 @@
const std = @import("std");
const mem = std.mem;
const io = std.io;
const fs = std.fs;
const posix = std.posix;
const assert = std.debug.assert;
const builtin = @import("builtin");
@ -73,15 +73,15 @@ fn _main() !void {
.{ .name = "h", .kind = .boolean },
.{ .name = "version", .kind = .boolean },
}).parse(std.os.argv[1..]) catch {
try io.getStdErr().writeAll(usage);
try fs.File.stderr().writeAll(usage);
posix.exit(1);
};
if (result.flags.h) {
try io.getStdOut().writeAll(usage);
try fs.File.stdout().writeAll(usage);
posix.exit(0);
}
if (result.flags.version) {
try io.getStdOut().writeAll(@import("build_options").version ++ "\n");
try fs.File.stdout().writeAll(@import("build_options").version ++ "\n");
posix.exit(0);
}
@ -125,8 +125,8 @@ fn callbackListener(_: *zriver.CommandCallbackV1, event: zriver.CommandCallbackV
switch (event) {
.success => |success| {
if (mem.len(success.output) > 0) {
const stdout = io.getStdOut().writer();
stdout.print("{s}\n", .{success.output}) catch @panic("failed to write to stdout");
var stdout = fs.File.stdout().writer(&.{});
stdout.interface.print("{s}\n", .{success.output}) catch @panic("failed to write to stdout");
}
posix.exit(0);
},
@ -134,7 +134,7 @@ fn callbackListener(_: *zriver.CommandCallbackV1, event: zriver.CommandCallbackV
// A small hack to provide usage text when river reports an unknown command.
if (mem.orderZ(u8, failure.failure_message, "unknown command") == .eq) {
std.log.err("unknown command", .{});
io.getStdErr().writeAll(usage) catch {};
fs.File.stderr().writeAll(usage) catch {};
posix.exit(1);
}
fatal("{s}", .{failure.failure_message});