-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.zig
41 lines (35 loc) · 1.32 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
const std = @import("std");
var filters: [1][]const u8 = undefined;
var filters_len: usize = 0;
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const test_filter = b.option([]const u8, "test-filter", "Filter the executed library tests");
const emit_docs = b.option(bool, "emit-docs", "Build library documentation") orelse false;
const module = b.addModule("hzzp", .{
.root_source_file = b.path("src/main.zig"),
});
const test_compile_step = b.addTest(.{
.root_source_file = module.root_source_file.?,
.target = target,
.optimize = optimize,
});
if (test_filter) |_| {
filters[0] = test_filter.?;
filters_len += 1;
}
test_compile_step.filters = filters[0..filters_len];
const test_run_step = b.addRunArtifact(test_compile_step);
const test_step = b.step("test", "Run all library tests");
if (emit_docs) {
const docs = b.addInstallDirectory(.{
.source_dir = test_compile_step.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "doc",
});
test_step.dependOn(&test_compile_step.step);
test_step.dependOn(&docs.step);
} else {
test_step.dependOn(&test_run_step.step);
}
}