commit 1481474a6a4a5622cff09017c16358173233cbc5
parent f05e6237f4f8b524fb700eaa3cca4a047c44fa77
Author: Sylvia Ivory <git@sivory.net>
Date: Tue, 13 Jan 2026 17:43:41 -0800
Create bin out of elf
Diffstat:
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/build.zig b/build.zig
@@ -43,7 +43,7 @@ fn add_exe(exe_name: []const u8, path: std.Build.LazyPath, b: *std.Build) !*std.
fn lab(name: []const u8, units: []const []const u8, b: *std.Build) !void {
for (units) |unit| {
- const exe_name = try std.fmt.allocPrint(b.allocator, "{s}_{s}", .{ name, unit });
+ const exe_name = try std.fmt.allocPrint(b.allocator, "{s}_{s}.elf", .{ name, unit });
defer b.allocator.free(exe_name);
const src_name = try std.fmt.allocPrint(b.allocator, "{s}.zig", .{exe_name});
@@ -80,7 +80,18 @@ fn lab(name: []const u8, units: []const []const u8, b: *std.Build) !void {
_ = try file.write(root_src);
file.close();
- _ = try add_exe(exe_name, relative_path, b);
+ const exe = try add_exe(exe_name, relative_path, b);
+
+ const bin_name = try std.fmt.allocPrint(b.allocator, "{s}_{s}.bin", .{ name, unit });
+ defer b.allocator.free(bin_name);
+
+ const copy = b.addObjCopy(exe.getEmittedBin(), .{
+ .format = .bin,
+ });
+ copy.step.dependOn(&exe.step);
+
+ const install_bin = b.addInstallBinFile(copy.getOutput(), bin_name);
+ b.getInstallStep().dependOn(&install_bin.step);
}
}