-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
71 lines (57 loc) · 2.06 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const dep_opts = .{ .target = target, .optimize = optimize };
const max_dependencies = b.option(
u8,
"max_dependencies",
"Set the maximum number of dependencies",
) orelse 16;
const max_subscribers = b.option(
u8,
"max_subscribers",
"Set the maximum number of subscribers",
) orelse 16;
const options = b.addOptions();
options.addOption(u32, "max_dependencies", max_dependencies);
options.addOption(u32, "max_subscribers", max_subscribers);
const zignals = b.addModule("zignals", .{
.root_source_file = b.path("src/root.zig"),
});
zignals.addOptions("config", options);
{
const tests = b.addTest(.{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
.test_runner = .{
.mode = .simple,
.path = b.path("test_runner.zig"),
},
});
tests.root_module.addOptions("config", options);
const run_test = b.addRunArtifact(tests);
run_test.has_side_effects = true;
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_test.step);
}
{
const bench = b.addTest(.{
.root_source_file = b.path("src/bench.zig"),
.target = target,
.optimize = .ReleaseFast,
.test_runner = .{
.mode = .simple,
.path = b.path("test_runner.zig"),
},
});
bench.root_module.addOptions("config", options);
const zbench = b.dependency("zbench", dep_opts).module("zbench");
bench.root_module.addImport("zbench", zbench);
const run_bench = b.addRunArtifact(bench);
run_bench.has_side_effects = true;
const bench_step = b.step("bench", "Run benchmarks");
bench_step.dependOn(&run_bench.step);
}
}