From f65fc23fdde7dd0860bdf4f9b9aee7b97ad5564c Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Mon, 2 Dec 2024 19:47:32 -0500 Subject: [PATCH] 2024: Add build.zig --- 2024/build.zig | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 2024/build.zig diff --git a/2024/build.zig b/2024/build.zig new file mode 100644 index 0000000..4c35945 --- /dev/null +++ b/2024/build.zig @@ -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); + } +}