summaryrefslogtreecommitdiff
path: root/vere/ext/tracy/build.zig
blob: c672126c768470e6340b59d07f144a1e32f1a9f1 (plain)
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
49
50
51
52
const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const tracy_src = b.dependency("tracy", .{
        .target = target,
        .optimize = optimize,
    });

    const tracy = b.addStaticLibrary(.{
        .name = "tracy",
        .target = target,
        .optimize = optimize,
    });

    tracy.linkLibC();
    tracy.linkLibCpp();

    // Add Tracy include path
    tracy.addIncludePath(tracy_src.path("public"));

    // Add Tracy C++ client source
    tracy.addCSourceFiles(.{
        .root = tracy_src.path("public"),
        .files = &.{"TracyClient.cpp"},
        .flags = &.{
            "-DTRACY_ENABLE",
            "-fno-sanitize=undefined",
            "-D_WIN32_WINNT=0x601", // Windows compatibility
            "-std=c++11",
        },
    });

    // Platform-specific libraries
    const t = target.result;
    if (t.os.tag == .linux) {
        tracy.linkSystemLibrary("pthread");
        tracy.linkSystemLibrary("dl");
    } else if (t.os.tag.isDarwin()) {
        // macOS might need additional frameworks
    } else if (t.os.tag == .windows) {
        tracy.linkSystemLibrary("ws2_32");
        tracy.linkSystemLibrary("dbghelp");
    }

    // Install Tracy headers for C API - install the entire public directory structure
    tracy.installHeadersDirectory(tracy_src.path("public"), "", .{});

    b.installArtifact(tracy);
}