1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const target = b.standardTargetOptions(.{});
5 const optimize = b.standardOptimizeOption(.{});
6
7 const opts = .{ .target = target, .optimize = optimize };
8 const zbench_module = b.dependency("zbench", opts).module("zbench");
9
10 const exe = b.addExecutable(.{
11 .name = "aoc2024",
12 .root_module = b.createModule(.{
13 .root_source_file = b.path("src/main.zig"),
14 .target = target,
15 .optimize = optimize,
16 .single_threaded = true,
17 }),
18 });
19
20 const bench = b.addExecutable(.{
21 .name = "bench",
22 .root_module = b.createModule(.{
23 .root_source_file = b.path("src/bench.zig"),
24 .target = target,
25 .optimize = optimize,
26 .single_threaded = true,
27 }),
28 });
29
30 bench.root_module.addImport("zbench", zbench_module);
31
32 b.installArtifact(exe);
33 b.installArtifact(bench);
34
35 const run_step = b.step("run", "Run the app");
36 const bench_step = b.step("bench", "Run the bench");
37
38 const run_cmd = b.addRunArtifact(exe);
39 run_step.dependOn(&run_cmd.step);
40
41 const bench_cmd = b.addRunArtifact(bench);
42 bench_step.dependOn(&bench_cmd.step);
43
44 run_cmd.step.dependOn(b.getInstallStep());
45
46 if (b.args) |args| {
47 run_cmd.addArgs(args);
48 }
49
50 const exe_tests = b.addTest(.{
51 .root_module = exe.root_module,
52 });
53
54 const run_exe_tests = b.addRunArtifact(exe_tests);
55
56 const test_step = b.step("test", "Run tests");
57 test_step.dependOn(&run_exe_tests.step);
58}