From 6d2576abeeecc7187ced8365ac865ed333fb876f Mon Sep 17 00:00:00 2001 From: Leah Amelia Chen Date: Fri, 19 Sep 2025 00:35:09 +0200 Subject: [PATCH] build: explicitly suffix Zig files 2: Electric Boogaloo Of *course* I missed one --- src/build/GhosttyFrameData.zig | 7 +++++-- src/build/framegen/main.zig | 16 +++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/build/GhosttyFrameData.zig b/src/build/GhosttyFrameData.zig index 3dc638a05..1644388bc 100644 --- a/src/build/GhosttyFrameData.zig +++ b/src/build/GhosttyFrameData.zig @@ -25,11 +25,14 @@ pub fn init(b: *std.Build) !GhosttyFrameData { }); const run = b.addRunArtifact(exe); + // Both the compressed framedata and the Zig source file + // have to be put in the same directory, since the compressed file + // has to be within the source file's include path. + const dir = run.addOutputDirectoryArg("framedata"); - _ = run.addOutputFileArg("framedata.compressed"); return .{ .exe = exe, - .output = run.captureStdOut(), + .output = dir.path(b, "framedata.zig"), }; } diff --git a/src/build/framegen/main.zig b/src/build/framegen/main.zig index 1be33eb11..f4a7d9443 100644 --- a/src/build/framegen/main.zig +++ b/src/build/framegen/main.zig @@ -9,12 +9,12 @@ pub fn main() !void { // Skip the exe name _ = arg_iter.skip(); - const output_path = arg_iter.next() orelse return error.MissingOutputPath; + const out_dir_path = arg_iter.next() orelse return error.MissingOutputPath; + const compressed_out = "framedata.compressed"; + const zig_out = "framedata.zig"; - const out_dir_path = fs.path.dirname(output_path) orelse return error.InvalidOutputPath; const out_dir = try fs.cwd().openDir(out_dir_path, .{}); - - const compressed_file = try out_dir.createFile(fs.path.basename(output_path), .{}); + const compressed_file = try out_dir.createFile(compressed_out, .{}); // Join the frames with a null byte. We'll split on this later const all_frames = try std.mem.join(gpa.allocator(), "\x01", &frames); @@ -23,13 +23,15 @@ pub fn main() !void { const reader = fbs.reader(); try std.compress.flate.compress(reader, compressed_file.writer(), .{}); - const stdout = std.io.getStdOut().writer(); + const compressed_path = try std.fs.path.join(gpa.allocator(), &.{ out_dir_path, compressed_out }); - try stdout.print( + const zig_file = try out_dir.createFile(zig_out, .{}); + + try zig_file.writer().print( \\//! This file is auto-generated. Do not edit. \\ \\pub const compressed = @embedFile("{s}"); - , .{output_path}); + , .{compressed_path}); } const frames = [_][]const u8{