cerrado @ zig

 1const std = @import("std");
 2
 3pub fn build(b: *std.Build) void {
 4    const target = b.standardTargetOptions(.{});
 5
 6    const optimize = b.standardOptimizeOption(.{});
 7
 8    const lib = b.addStaticLibrary(.{
 9        .name = "cerrado",
10
11        .root_source_file = b.path("src/root.zig"),
12        .target = target,
13        .optimize = optimize,
14    });
15
16    b.installArtifact(lib);
17
18    const exe = b.addExecutable(.{
19        .name = "cerrado",
20        .root_source_file = b.path("src/main.zig"),
21        .target = target,
22        .optimize = optimize,
23        .link_libc = true,
24    });
25
26    exe.linkSystemLibrary("git2");
27
28    b.installArtifact(exe);
29
30    const run_cmd = b.addRunArtifact(exe);
31
32    run_cmd.step.dependOn(b.getInstallStep());
33
34    if (b.args) |args| {
35        run_cmd.addArgs(args);
36    }
37
38    const run_step = b.step("run", "Run the app");
39    run_step.dependOn(&run_cmd.step);
40
41    const lib_unit_tests = b.addTest(.{
42        .root_source_file = b.path("src/root.zig"),
43        .target = target,
44        .optimize = optimize,
45        .link_libc = true,
46    });
47
48    lib_unit_tests.linkSystemLibrary("git2");
49
50    const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
51
52    const exe_unit_tests = b.addTest(.{
53        .root_source_file = b.path("src/main.zig"),
54        .target = target,
55        .optimize = optimize,
56    });
57
58    const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
59
60    const test_step = b.step("test", "Run unit tests");
61    test_step.dependOn(&run_lib_unit_tests.step);
62    test_step.dependOn(&run_exe_unit_tests.step);
63}