Skip to content
zit Artifact [52f673e950]
Login

Artifact [52f673e950]

Artifact 52f673e9501bbe1fa1ea095a58c96e68c4a356792780962d70ec92a0b631a714:


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);
}