-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.zig
49 lines (40 loc) · 1.4 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const std = @import("std");
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const lib = b.addStaticLibrary(
.{
.name = "base32",
.root_source_file = b.path("src/base32.zig"),
.target = target,
.optimize = optimize,
},
);
// This declares intent for the library to be installed into the standard
// location when the user invokes the "install" step (the default step when
// running `zig build`).
b.installArtifact(lib);
// This adds a module which allows it to be imported as module with Zon
_ = b.addModule("base32", .{
.root_source_file = b.path("src/base32.zig"),
});
const coverage = b.option(bool, "coverage", "Generate test coverage") orelse false;
var main_tests = b.addTest(
.{
.root_source_file = b.path("src/base32.zig"),
.optimize = optimize,
},
);
const run_main_tests = b.addRunArtifact(main_tests);
if (coverage) {
main_tests.setExecCmd(&[_]?[]const u8{
"kcov",
"--clean",
"--include-path=./src/",
"kcov-output",
null, // to get zig to use the --test-cmd-bin flag
});
}
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&run_main_tests.step);
}