biff8/build.zig

47 lines
1.5 KiB
Zig

const std = @import("std");
const Coverage = @import("build/Coverage.zig");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// The public module. Consumers `@import("biff8")`.
const mod = b.addModule("biff8", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
// Tests: one binary rooted at src/root.zig. `refAllDecls` in
// root.zig's test block pulls in every file's tests through the
// import graph.
const tests = b.addTest(.{ .root_module = mod });
const test_step = b.step("test", "Run all tests");
test_step.dependOn(&b.addRunArtifact(tests).step);
const lib = b.addLibrary(.{
.name = "biff8",
.root_module = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
}),
});
const docs_step = b.step("docs", "Generate documentation");
docs_step.dependOn(&b.addInstallDirectory(.{
.source_dir = lib.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
}).step);
// Coverage: `zig build coverage` (kcov, Linux x86_64/aarch64 only)
{
var cov = Coverage.init(b);
const cov_mod = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
_ = cov.addModule(cov_mod, "biff8");
}
}