const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// The zit library: a Zig implementation of the Fossil formats and protocol
// as specified by the four RFC drafts in docs/rfcs/.
const mod = b.addModule("zit", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
});
// The `zit` command-line tool.
const exe = b.addExecutable(.{
.name = "zit",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zit", .module = mod },
},
}),
});
b.installArtifact(exe);
// `zig build run -- <args>`
const run_step = b.step("run", "Run the zit CLI");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| run_cmd.addArgs(args);
// `zig build test` — runs library + CLI unit tests.
const test_step = b.step("test", "Run unit tests");
const mod_tests = b.addTest(.{ .root_module = mod });
test_step.dependOn(&b.addRunArtifact(mod_tests).step);
const exe_tests = b.addTest(.{ .root_module = exe.root_module });
test_step.dependOn(&b.addRunArtifact(exe_tests).step);
// `zig build fuzz -- <target> [--seed N] [--rounds N]` — seeded deterministic
// fuzz targets, driven in a loop by an out-of-band runner; not part of `test`.
const fuzz_exe = b.addExecutable(.{
.name = "fuzz",
.root_module = b.createModule(.{
.root_source_file = b.path("src/fuzz_tests.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "zit", .module = mod }},
}),
});
const fuzz_step = b.step("fuzz", "Run a seeded fuzz target (zig build fuzz -- <target> --seed N)");
const fuzz_run = b.addRunArtifact(fuzz_exe);
if (b.args) |args| fuzz_run.addArgs(args);
fuzz_step.dependOn(&fuzz_run.step);
// `zig build dst [-- --seed N | --seeds K] [--steps M]` — deterministic
// simulation of the repostate derivation. No args runs the fixed smoke
// sweep (seeds 1..25 x 10_000 steps); deep sweeps pass `--seeds`.
const dst_exe = b.addExecutable(.{
.name = "dst",
.root_module = b.createModule(.{
.root_source_file = b.path("src/dst.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "zit", .module = mod }},
}),
});
const dst_step = b.step("dst", "Deterministic simulation (default smoke sweep; zig build dst -- --seed N)");
const dst_run = b.addRunArtifact(dst_exe);
if (b.args) |args| dst_run.addArgs(args);
dst_step.dependOn(&dst_run.step);
// `bench` and `smoke` are wired at later milestones (a benchmark suite,
// and a bounded Fossil interop check run only at layer milestones); until
// then they exist as named steps that fail loudly rather than silently
// passing.
const bench_step = b.step("bench", "Benchmarks");
bench_step.dependOn(&b.addFail("bench: no benchmark exists yet").step);
const smoke_step = b.step("smoke", "Fossil interop smoke check (milestone-manual)");
smoke_step.dependOn(&b.addFail("smoke: wired at layer milestones only").step);
}