diff --git a/README.md b/README.md index e8f8dc64829acd6c64698398b740958f7c645296..f0986ea46b013b76095fe99d5ec1a40945d3a41b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ in your program: ```zig const std = @import("std"); const tracer = @import("tracer"); -const build_options = @import("build_options"); +pub const build_options = @import("build_options"); pub const tracer_impl = tracer.spall; // supports none, log, spall out of the box diff --git a/build.zig b/build.zig index 1eae7a4c64c77acf89e35144da6c88c726182f9b..5e0595221ab3cbfb04f4403800716d9161e2218b 100644 --- a/build.zig +++ b/build.zig @@ -4,22 +4,19 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; + const mod = b.addModule("tracer", .{ .source_file = .{ .path = "src/mod.zig" } }); + + const options = b.addOptions(); + options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len); + const exe = b.addExecutable(.{ .name = "test", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = mode, }); + exe.linkLibC(); + exe.addModule("tracer", mod); + exe.addOptions("build_options", options); b.installArtifact(exe); - - const run_cmd = b.addRunArtifact(exe); - - run_cmd.step.dependOn(b.getInstallStep()); - - if (b.args) |args| { - run_cmd.addArgs(args); - } - - const run_step = b.step("run", "Run the app"); - run_step.dependOn(&run_cmd.step); } diff --git a/src/main.zig b/src/main.zig index f92e18124bb86f9b42fa47ec0a8291c7b0d9ad35..b78557d482999d07cfc3395a35b688b97a75d644 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,5 +1,24 @@ const std = @import("std"); +const tracer = @import("tracer"); +pub const build_options = @import("build_options"); + +pub const tracer_impl = tracer.spall; pub fn main() !void { - std.debug.print("All your {s} are belong to us.\n", .{"codebase"}); + try tracer.init(); + defer tracer.deinit(); + + // main loop + var go = false; + while (go) { + try tracer.init2(); + defer tracer.deinit2(); + + handler(); + } +} + +fn handler() void { + const t = tracer.trace(@src()); + defer t.end(); }