-
Notifications
You must be signed in to change notification settings - Fork 7
/
build_tracy.zig
32 lines (28 loc) · 1.22 KB
/
build_tracy.zig
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
const std = @import("std");
const Builder = std.build.Builder;
const LibExeObjStep = std.build.LibExeObjStep;
/// Build required sources, use tracy by importing "tracy.zig"
pub fn link(b: *Builder, step: *LibExeObjStep, opt_path: ?[]const u8) void {
const step_options = b.addOptions();
step.addOptions("build_options", step_options);
step_options.addOption(bool, "tracy_enabled", opt_path != null);
if (opt_path) |path| {
step.addIncludePath(path);
const tracy_client_source_path = std.fs.path.join(step.builder.allocator, &.{ path, "TracyClient.cpp" }) catch unreachable;
step.addCSourceFile(tracy_client_source_path, &[_][]const u8{
"-DTRACY_ENABLE",
// MinGW doesn't have all the newfangled windows features,
// so we need to pretend to have an older windows version.
"-D_WIN32_WINNT=0x601",
"-fno-sanitize=undefined",
});
step.linkLibC();
step.linkSystemLibrary("c++");
if (step.target.isWindows()) {
step.linkSystemLibrary("Advapi32");
step.linkSystemLibrary("User32");
step.linkSystemLibrary("Ws2_32");
step.linkSystemLibrary("DbgHelp");
}
}
}