const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); // ReleaseFast by default: a Debug server is 10-200x slower (measured in // tests/e2e/compare-run.sh). Devs can still opt into Debug or // ReleaseSafe with -Doptimize=Debug / -Doptimize=ReleaseSafe. const optimize = b.option(std.builtin.OptimizeMode, "optimize", "Prioritize performance, safety, or binary size") orelse .ReleaseFast; const lib_mod = b.createModule(.{ .root_source_file = b.path("src/lib.zig"), .target = target, .optimize = optimize, }); const exe_mod = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "mongo", .module = lib_mod }, }, }); const exe = b.addExecutable(.{ .name = "multiforadb", .root_module = exe_mod, }); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| run_cmd.addArgs(args); const run_step = b.step("run", "Run multiforadb server"); run_step.dependOn(&run_cmd.step); const test_mod = b.createModule(.{ .root_source_file = b.path("src/lib.zig"), .target = target, .optimize = optimize, }); const test_step = b.addTest(.{ .root_module = test_mod, }); const run_tests = b.addRunArtifact(test_step); const test_help = b.step("test", "Run unit tests"); test_help.dependOn(&run_tests.step); // The B+tree harnesses were in no build step, so `zig build test` -- which // only compiles src/lib.zig's test block -- could not see an API break in // them. They are also the only coverage for records past the inline limit // and for randomized split/remove interleavings, i.e. exactly what M0's // arena work puts at risk. Wire them up so they cannot rot unnoticed. // // Kept out of `test` because stress.zig runs for seconds and the three // main harnesses print rather than assert-and-exit; `zig build fuzz` is // the gate to run alongside the e2e matrix on any index change. const fuzz_step = b.step("fuzz", "Run the B+tree stress and fuzz harnesses"); const fuzz_split_mod = b.createModule(.{ .root_source_file = b.path("src/fuzz_split.zig"), .target = target, .optimize = optimize, }); const fuzz_split = b.addTest(.{ .root_module = fuzz_split_mod }); fuzz_step.dependOn(&b.addRunArtifact(fuzz_split).step); for ([_][]const u8{ "spill", "spill2", "stress" }) |name| { const mod = b.createModule(.{ .root_source_file = b.path(b.fmt("src/{s}.zig", .{name})), .target = target, .optimize = optimize, }); const harness = b.addExecutable(.{ .name = name, .root_module = mod }); fuzz_step.dependOn(&b.addRunArtifact(harness).step); } }