-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.zig
47 lines (37 loc) · 1.42 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
const std = @import("std");
const builtin = @import("builtin");
const Build = std.Build;
const Module = Build.Module;
const OptimizeMode = std.builtin.OptimizeMode;
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const msgpack = b.addModule("msgpack", .{
.root_source_file = b.path(b.pathJoin(&.{ "src", "msgpack.zig" })),
});
generateDocs(b, optimize, target);
const test_step = b.step("test", "Run unit tests");
const msgpack_unit_tests = b.addTest(.{
.root_source_file = b.path(b.pathJoin(&.{ "src", "test.zig" })),
.target = target,
.optimize = optimize,
});
msgpack_unit_tests.root_module.addImport("msgpack", msgpack);
const run_msgpack_tests = b.addRunArtifact(msgpack_unit_tests);
test_step.dependOn(&run_msgpack_tests.step);
}
fn generateDocs(b: *Build, optimize: OptimizeMode, target: Build.ResolvedTarget) void {
const lib = b.addObject(.{
.name = "zig-msgpack",
.root_source_file = b.path(b.pathJoin(&.{ "src", "msgpack.zig" })),
.target = target,
.optimize = optimize,
});
const docs_step = b.step("docs", "Emit docs");
const docs_install = b.addInstallDirectory(.{
.source_dir = lib.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
});
docs_step.dependOn(&docs_install.step);
}