build: explicitly suffix Zig files 2: Electric Boogaloo

Of *course* I missed one
pull/8769/head
Leah Amelia Chen 2025-09-19 00:35:09 +02:00
parent 9b40e03c40
commit 6d2576abee
No known key found for this signature in database
2 changed files with 14 additions and 9 deletions

View File

@ -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"),
};
}

View File

@ -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{