mirror of
https://codeberg.org/andyscott/advent-of-code.git
synced 2024-12-21 17:13:10 -05:00
2024: Add build.zig
This commit is contained in:
parent
1d466f970c
commit
f65fc23fdd
1 changed files with 33 additions and 0 deletions
33
2024/build.zig
Normal file
33
2024/build.zig
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue