2024: Add build.zig

This commit is contained in:
Andrew Scott 2024-12-02 19:47:32 -05:00
parent 1d466f970c
commit f65fc23fdd
Signed by: a
GPG key ID: 7CD5A5977E4931C1

33
2024/build.zig Normal file
View file

@ -0,0 +1,33 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const install_all = b.step("install-all", "Install all days");
const run_all = b.step("run-all", "Run all days");
const num_days = b.option(u32, "num-days", "The number of days to process") orelse 25;
var day: u8 = 1;
while (day <= num_days) : (day += 1) {
const str = b.fmt("day{d}", .{day});
const file = b.fmt("{s}.zig", .{str});
const exe = b.addExecutable(.{
.name = str,
.root_source_file = b.path(file),
.target = target,
.optimize = optimize,
});
const install_exe = b.addInstallArtifact(exe, .{});
const install_step = b.step(b.fmt("install_{s}", .{str}), b.fmt("Install {s}", .{str}));
install_step.dependOn(&install_exe.step);
install_all.dependOn(&install_exe.step);
const run_exe = b.addRunArtifact(exe);
const run_step = b.step(b.fmt("run_{s}", .{str}), b.fmt("Run {s}", .{str}));
run_step.dependOn(&run_exe.step);
run_all.dependOn(&run_exe.step);
}
}