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 {...@@ -6,11 +6,18 @@ pub fn build(b: *std.Build) void {
66
7 const mod = b.addModule("tracer", .{ .source_file = .{ .path = "src/mod.zig" } });7 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 {
9 const options = b.addOptions();15 const options = b.addOptions();
10 options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len);16 options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len);
17 options.addOption(u8, "backend", backend);
1118
12 const exe = b.addExecutable(.{19 const exe = b.addExecutable(.{
13 .name = "test",20 .name = "test" ++ std.fmt.comptimePrint("{d}", .{backend}),
14 .root_source_file = .{ .path = "src/main.zig" },21 .root_source_file = .{ .path = "src/main.zig" },
15 .target = target,22 .target = target,
16 .optimize = mode,23 .optimize = mode,
src/main.zig+6-1
...@@ -2,7 +2,12 @@ const std = @import("std");...@@ -2,7 +2,12 @@ const std = @import("std");
2const tracer = @import("tracer");2const tracer = @import("tracer");
3pub const build_options = @import("build_options");3pub 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
7pub fn main() !void {12pub fn main() !void {
8 try tracer.init();13 try tracer.init();