-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
82 lines (71 loc) · 2.16 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mzg = b.addModule(
"mzg",
.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
},
);
const lib = b.addLibrary(.{
.linkage = .static,
.name = "mzg",
.root_module = mzg,
});
b.installArtifact(lib);
const tests = b.addTest(.{
.root_source_file = b.path("tests/all.zig"),
});
tests.root_module.addImport("mzg", mzg);
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("mzg-test", "Run unit tests");
test_step.dependOn(&run_tests.step);
inline for (.{
"array",
"default",
"map",
"simple",
"stream",
}) |name| {
const example = b.addExecutable(.{
.name = "mzg-example-" ++ name,
.root_source_file = b.path("examples/" ++ name ++ ".zig"),
.target = target,
.optimize = optimize,
});
example.root_module.addImport("mzg", mzg);
b.installArtifact(example);
const run_example = b.addRunArtifact(example);
const run_example_step = b.step(
"mzg-example-" ++ name,
"Run the mzg " ++ name ++ " example",
);
run_example_step.dependOn(&run_example.step);
}
const docs = b.addInstallDirectory(.{
.install_dir = .prefix,
.install_subdir = "docs",
.source_dir = lib.getEmittedDocs(),
});
const docs_step = b.step("mzg-docs", "Emit documentation");
docs_step.dependOn(&docs.step);
const format = b.addFmt(.{
.check = true,
.paths = &.{
"src/",
"examples/",
"tests/",
"build.zig",
"build.zig.zon",
},
});
const format_step = b.step("mzg-fmt", "Format project");
format_step.dependOn(&format.step);
const all = b.step("mzg-all", "Run all steps");
all.dependOn(test_step);
all.dependOn(docs_step);
all.dependOn(format_step);
}