This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
48 lines (39 loc) · 1.44 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
const std = @import("std");
var mod: *std.Build.Module = undefined;
fn link(exe: *std.Build.CompileStep, add_coz: bool) void {
exe.addModule("signals", mod);
if (add_coz) {
exe.linkLibC();
exe.addLibraryPath(.{ .path = "/usr/lib/coz-profiler" });
exe.linkSystemLibrary("coz");
exe.addCSourceFiles(&.{"src/coz.c"}, &.{});
}
}
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const opt_test_filter = b.option([]const u8, "test-filter", "test filter");
const opt_use_coz = b.option(bool, "coz", "Enable coz profiler") orelse false;
mod = b.addModule("signals", .{
.source_file = .{ .path = "src/main.zig" },
});
const bench = b.addExecutable(.{
.name = "bench",
.root_source_file = .{ .path = "src/tests.zig" },
});
link(bench, opt_use_coz);
b.installArtifact(bench);
const bench_step = b.step("bench", "Run benchmarks");
bench_step.dependOn(&b.addRunArtifact(bench).step);
const tests = b.addTest(.{
.root_source_file = .{ .path = "src/tests.zig" },
.target = target,
.optimize = optimize,
});
if (opt_test_filter) |x| tests.filter = x;
link(tests, false);
b.installArtifact(tests);
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&run_tests.step);
}