-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.zig
83 lines (69 loc) · 2.74 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
83
const std = @import("std");
const package_name = "json";
const package_path = "src/json.zig";
const test_path = "tests/test.zig";
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Dependencies.
const dep_opts = .{ .target = target, .optimize = optimize };
const getty_module = b.dependency("getty", dep_opts).module("getty");
const protest_module = b.dependency("protest", dep_opts).module("protest");
// Export Getty JSON as a module.
const json_module = b.addModule(package_name, .{
.root_source_file = b.path(package_path),
.imports = &.{
.{ .name = "getty", .module = getty_module },
.{ .name = "protest", .module = protest_module },
},
});
// Tests.
{
const test_all_step = b.step("test", "Run tests");
const test_ser_step = b.step("test-ser", "Run serialization tests");
const test_de_step = b.step("test-de", "Run deserialization tests");
// Serialization tests.
const t_ser = b.addTest(.{
.name = "serialization test",
.root_source_file = b.path("tests/test.zig"),
.target = target,
.optimize = optimize,
.filter = "encode",
});
t_ser.root_module.addImport("json", json_module);
t_ser.root_module.addImport("getty", getty_module);
t_ser.root_module.addImport("protest", protest_module);
test_ser_step.dependOn(&b.addRunArtifact(t_ser).step);
test_all_step.dependOn(test_ser_step);
// Deserialization tests.
const t_de = b.addTest(.{
.name = "deserialization test",
.root_source_file = b.path("tests/test.zig"),
.target = target,
.optimize = optimize,
.filter = "parse",
});
t_de.root_module.addImport("json", json_module);
t_de.root_module.addImport("getty", getty_module);
t_de.root_module.addImport("protest", protest_module);
test_de_step.dependOn(&b.addRunArtifact(t_de).step);
test_all_step.dependOn(test_de_step);
}
// Documentation.
{
const docs_step = b.step("docs", "Build the project documentation");
const doc_obj = b.addObject(.{
.name = "docs",
.root_source_file = b.path(package_path),
.target = target,
.optimize = optimize,
});
doc_obj.root_module.addImport("getty", getty_module);
const install_docs = b.addInstallDirectory(.{
.source_dir = doc_obj.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs/json",
});
docs_step.dependOn(&install_docs.step);
}
}