build: explicitly suffix Zig files 2: Electric Boogaloo
Of *course* I missed onepull/8769/head
parent
9b40e03c40
commit
6d2576abee
|
|
@ -25,11 +25,14 @@ pub fn init(b: *std.Build) !GhosttyFrameData {
|
||||||
});
|
});
|
||||||
|
|
||||||
const run = b.addRunArtifact(exe);
|
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 .{
|
return .{
|
||||||
.exe = exe,
|
.exe = exe,
|
||||||
.output = run.captureStdOut(),
|
.output = dir.path(b, "framedata.zig"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ pub fn main() !void {
|
||||||
// Skip the exe name
|
// Skip the exe name
|
||||||
_ = arg_iter.skip();
|
_ = 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 out_dir = try fs.cwd().openDir(out_dir_path, .{});
|
||||||
|
const compressed_file = try out_dir.createFile(compressed_out, .{});
|
||||||
const compressed_file = try out_dir.createFile(fs.path.basename(output_path), .{});
|
|
||||||
|
|
||||||
// Join the frames with a null byte. We'll split on this later
|
// Join the frames with a null byte. We'll split on this later
|
||||||
const all_frames = try std.mem.join(gpa.allocator(), "\x01", &frames);
|
const all_frames = try std.mem.join(gpa.allocator(), "\x01", &frames);
|
||||||
|
|
@ -23,13 +23,15 @@ pub fn main() !void {
|
||||||
const reader = fbs.reader();
|
const reader = fbs.reader();
|
||||||
try std.compress.flate.compress(reader, compressed_file.writer(), .{});
|
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.
|
\\//! This file is auto-generated. Do not edit.
|
||||||
\\
|
\\
|
||||||
\\pub const compressed = @embedFile("{s}");
|
\\pub const compressed = @embedFile("{s}");
|
||||||
, .{output_path});
|
, .{compressed_path});
|
||||||
}
|
}
|
||||||
|
|
||||||
const frames = [_][]const u8{
|
const frames = [_][]const u8{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue