Refine setup
This commit is contained in:
parent
f4670e510f
commit
d64050a402
16 changed files with 4158 additions and 30 deletions
48
build.zig
48
build.zig
|
|
@ -1,35 +1,33 @@
|
|||
const std = @import("std");
|
||||
|
||||
const nr_of_days = 12;
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
// TODO: This should be a non-exhaustive enum with one option: all
|
||||
const day = b.option(u8, "day", "Build day") orelse 1;
|
||||
const run_all = b.step("run", "Run all days");
|
||||
|
||||
// TODO: Depending on the day chosen, only that day should compile, or all days
|
||||
const exe = addDay(b, target, optimize, day);
|
||||
b.installArtifact(exe);
|
||||
const day_option = b.option(usize, "day", "Build day");
|
||||
|
||||
// run step
|
||||
const run_exe = b.addRunArtifact(exe);
|
||||
const run_step = b.step("run", "Run the binary");
|
||||
run_step.dependOn(&run_exe.step);
|
||||
}
|
||||
|
||||
fn addDay(
|
||||
b: *std.Build,
|
||||
target: std.Build.ResolvedTarget,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
day: u8,
|
||||
) *std.Build.Step.Compile {
|
||||
return b.addExecutable(.{
|
||||
.name = "aoc2025",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path(b.fmt("src/day_{d}.zig", .{day})),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
}),
|
||||
});
|
||||
for (1..nr_of_days + 1) |day| {
|
||||
const exe = b.addExecutable(.{
|
||||
.name = b.fmt("run-day{d:0>2}", .{day}),
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
}),
|
||||
});
|
||||
exe.root_module.addAnonymousImport("day", .{
|
||||
.root_source_file = b.path(b.fmt("src/days/day{d:0>2}.zig", .{day})),
|
||||
});
|
||||
b.installArtifact(exe);
|
||||
|
||||
if (day_option == null or day_option == day) {
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_all.dependOn(&run_cmd.step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue