-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
63 lines (50 loc) · 1.85 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
const std = @import("std");
const print = std.debug.print;
// FIXME: How do we retrieve this from the .zon file instead?
const version = std.SemanticVersion{ .major = 0, .minor = 1, .patch = 0 };
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
unitTests(b, target, optimize);
benchmarks(b, target, optimize);
}
fn unitTests(
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode
) void {
const test_step = b.step("test", "Run unit tests");
const tests = [_]*std.Build.Step.Compile{
b.addTest(.{
.name = "test_index_set",
.root_source_file = .{ .path = "./src/index_set.zig" },
.target = target,
.optimize = optimize,
}),
};
for (tests) |tst| {
const test_artifact = b.addRunArtifact(tst);
test_step.dependOn(&test_artifact.step);
}
}
fn benchmarks(
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode
) void {
const bench_step = b.step("bench", "Run benchmarks");
const opts = .{ .target = target, .optimize = optimize };
const zbench_module = b.dependency("zbench", opts).module("zbench");
// No clue what the proper way of doing this is..
const index_set_module = b.createModule(.{ .root_source_file = .{.path = "./src/index_set.zig"} });
const benches = b.addExecutable(.{
.name = "bench_compare",
.root_source_file = .{ .path = "bench/indexset_compare.zig" },
.target = target,
.optimize = optimize,
});
benches.root_module.addImport("zbench", zbench_module);
benches.root_module.addImport("index_set", index_set_module);
const bench_artifact = b.addRunArtifact(benches);
bench_step.dependOn(&bench_artifact.step);
}