From 3cd8cdb2ce58437e715ed17c37ea1f60367ac564 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Tue, 27 Jun 2023 23:20:35 +0200 Subject: [PATCH] work around zig json bug --- build_common.zig | 4 +++- mzte-nv/build.zig | 2 +- scripts/mzteinit/build.zig | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build_common.zig b/build_common.zig index 55debed..828e3aa 100644 --- a/build_common.zig +++ b/build_common.zig @@ -17,7 +17,9 @@ pub fn confgenGet(comptime T: type, root_path: []const u8, alloc: std.mem.Alloca .init(alloc, buf_reader.reader()); defer reader.deinit(); + const ret = try std.json.parseFromTokenSource(T, alloc, &reader, confgen_json_opt); + // We just grab the value from the parse result as this data will almost certainly have been // allocated with the builder's arena anyways. - return (try std.json.parseFromTokenSource(T, alloc, &reader, confgen_json_opt)).value; + return ret.value; } diff --git a/mzte-nv/build.zig b/mzte-nv/build.zig index e145b46..b8f8ff4 100644 --- a/mzte-nv/build.zig +++ b/mzte-nv/build.zig @@ -20,7 +20,7 @@ pub fn build(b: *std.build.Builder) !void { const znvim_dep = b.dependency("znvim", .{ .target = target, .optimize = mode }); const cg_opt = try common.confgenGet(struct { - term_font: []const u8, + term_font: []u8, // TODO: this being non-const is a workaround for an std bug }, "..", b.allocator); const opts = b.addOptions(); diff --git a/scripts/mzteinit/build.zig b/scripts/mzteinit/build.zig index 822a34c..b134917 100644 --- a/scripts/mzteinit/build.zig +++ b/scripts/mzteinit/build.zig @@ -17,7 +17,7 @@ pub fn build(b: *std.build.Builder) !void { exe.addModule("ansi-term", b.dependency("ansi_term", .{}).module("ansi-term")); const cg_opt = try common.confgenGet(struct { - gtk_theme: []const u8, + gtk_theme: []u8, // TODO: this being non-const is a workaround for an std bug }, "../..", b.allocator); const opts = b.addOptions();