Skip to content

Add option for enabling callstack tracing #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ pub fn build(b: *std.Build) void {
"on_demand",
"Build tracy with TRACY_ON_DEMAND",
) orelse false,
.callstack = b.option(
u32,
"callstack",
"If > 0, Builds tracy with TRACY_USE_CALLSTACK and sets TRACY_CALLSTACK to the depth provided.",
) orelse 0,
.shared = b.option(
bool,
"shared",
Expand All @@ -43,6 +48,12 @@ pub fn build(b: *std.Build) void {
translate_c.addIncludePath(b.path("libs/tracy/tracy"));
translate_c.defineCMacro("TRACY_ENABLE", "");
translate_c.defineCMacro("TRACY_IMPORTS", "");
if (options.callstack > 0) {
translate_c.defineCMacro("TRACY_USE_CALLSTACK", "");
var callstack_buffer: [64]u8 = undefined;
const callstack = std.fmt.bufPrintIntToSlice(&callstack_buffer, @as(u32, options.callstack), 10, .lower, .{});
translate_c.defineCMacro("TRACY_CALLSTACK", callstack);
}

const ztracy = b.addModule("root", .{
.root_source_file = b.path("src/ztracy.zig"),
Expand Down
Loading