|
| 1 | +const std = @import("std"); |
| 2 | + |
| 3 | +pub fn build(b: *std.Build) void { |
| 4 | + const target = b.standardTargetOptions(.{}); |
| 5 | + const optimize = b.standardOptimizeOption(.{}); |
| 6 | + |
| 7 | + // -------------------------- Solution module --------------------------- \\ |
| 8 | + const resonant_collinearity = b.addModule("resonant_collinearity", .{ |
| 9 | + .root_source_file = b.path("src/resonant_collinearity.zig"), |
| 10 | + }); |
| 11 | + |
| 12 | + // -------------------------- Main executable --------------------------- \\ |
| 13 | + const resonant_collinearity_exe = b.addExecutable(.{ |
| 14 | + .name = "resonant_collinearity", |
| 15 | + .root_source_file = b.path("src/main.zig"), |
| 16 | + .target = target, |
| 17 | + .optimize = optimize, |
| 18 | + }); |
| 19 | + |
| 20 | + const yazap = b.dependency("yazap", .{}); |
| 21 | + resonant_collinearity_exe.root_module.addImport("yazap", yazap.module("yazap")); |
| 22 | + resonant_collinearity_exe.root_module.addImport("resonant_collinearity", resonant_collinearity); |
| 23 | + b.installArtifact(resonant_collinearity_exe); |
| 24 | + |
| 25 | + const run_cmd = b.addRunArtifact(resonant_collinearity_exe); |
| 26 | + run_cmd.step.dependOn(b.getInstallStep()); |
| 27 | + if (b.args) |args| { |
| 28 | + run_cmd.addArgs(args); |
| 29 | + } |
| 30 | + |
| 31 | + const run_step = b.step("run", "Run Resonant Collinearity (day 08) app"); |
| 32 | + run_step.dependOn(&run_cmd.step); |
| 33 | + |
| 34 | + // --------------------------- Example tests ---------------------------- \\ |
| 35 | + const resonant_collinearity_tests = b.addTest(.{ |
| 36 | + .name = "resonant_collinearity_tests", |
| 37 | + .root_source_file = b.path("tests/example_tests.zig"), |
| 38 | + .target = target, |
| 39 | + .optimize = optimize, |
| 40 | + }); |
| 41 | + |
| 42 | + resonant_collinearity_tests.root_module.addImport("resonant_collinearity", resonant_collinearity); |
| 43 | + inline for (1..6) |i| { |
| 44 | + const num_str = std.fmt.comptimePrint("{!}", .{i}); |
| 45 | + resonant_collinearity_tests.root_module.addAnonymousImport( |
| 46 | + "example_input_" ++ num_str, |
| 47 | + .{ |
| 48 | + .root_source_file = b.path("input/example_input_" ++ num_str ++ ".txt"), |
| 49 | + }, |
| 50 | + ); |
| 51 | + } |
| 52 | + b.installArtifact(resonant_collinearity_tests); |
| 53 | + |
| 54 | + const test_step = b.step("test", "Run Resonant Collinearity (day 08) tests"); |
| 55 | + test_step.dependOn(&b.addRunArtifact(resonant_collinearity_tests).step); |
| 56 | + |
| 57 | + // ------------------------- Puzzle benchmarks -------------------------- \\ |
| 58 | + const resonant_collinearity_benchmarks = b.addExecutable(.{ |
| 59 | + .name = "resonant_collinearity_benchmarks", |
| 60 | + .root_source_file = b.path("benchmarks/puzzle_benchmarks.zig"), |
| 61 | + .target = target, |
| 62 | + .optimize = optimize, |
| 63 | + }); |
| 64 | + |
| 65 | + const zbench = b.dependency("zbench", .{ |
| 66 | + .target = target, |
| 67 | + .optimize = optimize, |
| 68 | + }); |
| 69 | + resonant_collinearity_benchmarks.root_module.addImport("zbench", zbench.module("zbench")); |
| 70 | + resonant_collinearity_benchmarks.root_module.addImport("resonant_collinearity", resonant_collinearity); |
| 71 | + resonant_collinearity_benchmarks.root_module.addAnonymousImport("puzzle_input", .{ |
| 72 | + .root_source_file = b.path("input/puzzle_input.txt"), |
| 73 | + }); |
| 74 | + b.installArtifact(resonant_collinearity_benchmarks); |
| 75 | + |
| 76 | + const benchmark_step = b.step("benchmark", "Run Resonant Collinearity (day 08) benchmarks"); |
| 77 | + benchmark_step.dependOn(&b.addRunArtifact(resonant_collinearity_benchmarks).step); |
| 78 | +} |
0 commit comments