authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-09-20 15:59:28 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-09-20 15:59:28 -07:00
log387db22fb347b1dfa8b4914a88ec254c8c6d5919
tree9f1b54a1d5629d20e528a7d109c28e2652994a6e
parent00a7cdb7d1fc8936a070e44c311b07a4aa4c464f

test all backends


2 files changed, 14 insertions(+), 2 deletions(-)

build.zig+8-1
......@@ -6,11 +6,18 @@ pub fn build(b: *std.Build) void {
66
77 const mod = b.addModule("tracer", .{ .source_file = .{ .path = "src/mod.zig" } });
88
9 addTest(b, target, mode, mod, 0);
10 addTest(b, target, mode, mod, 1);
11 addTest(b, target, mode, mod, 2);
12}
13
14fn addTest(b: *std.Build, target: std.zig.CrossTarget, mode: std.builtin.Mode, mod: *std.build.Module, comptime backend: u8) void {
915 const options = b.addOptions();
1016 options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len);
17 options.addOption(u8, "backend", backend);
1118
1219 const exe = b.addExecutable(.{
13 .name = "test",
20 .name = "test" ++ std.fmt.comptimePrint("{d}", .{backend}),
1421 .root_source_file = .{ .path = "src/main.zig" },
1522 .target = target,
1623 .optimize = mode,
src/main.zig+6-1
......@@ -2,7 +2,12 @@ const std = @import("std");
22const tracer = @import("tracer");
33pub const build_options = @import("build_options");
44
5pub const tracer_impl = tracer.spall;
5pub const tracer_impl = switch (build_options.backend) {
6 0 => tracer.none,
7 1 => tracer.log,
8 2 => tracer.spall,
9 else => unreachable,
10};
611
712pub fn main() !void {
813 try tracer.init();