65 lines
2.3 KiB
Zig
65 lines
2.3 KiB
Zig
const std = @import("std");
|
|
const bh = @import("bh");
|
|
|
|
const tracy_path = "tracy-0.10/public";
|
|
const tracy_path_include = tracy_path ++ "/tracy";
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const opts = bh.declareOptions(b);
|
|
|
|
//const tracy_enabled = b.option(bool, "tracy", "Enables tracy integration") orelse false;
|
|
|
|
const tracy_enabled: bool = false; //if (b.graph.env_map.hash_map.get("WITH_TRACY") != null) true else false;
|
|
// if (b.graph.env_map.hash_map.get("WITH_TRACY")) |with_tracy| {
|
|
// tracy_enabled = with_tracy;
|
|
// }
|
|
// std.debug.print("tracy enabled {s}\n", .{if (tracy_enabled) "true" else "false"});
|
|
|
|
const mod = b.addModule("tracy", .{
|
|
.target = opts.target,
|
|
.optimize = opts.optimize,
|
|
.root_source_file = b.path("tracy.zig"),
|
|
.link_libc = tracy_enabled,
|
|
.link_libcpp = tracy_enabled,
|
|
});
|
|
|
|
if (tracy_enabled) {
|
|
mod.addIncludePath(b.path(tracy_path_include));
|
|
mod.addCSourceFile(.{
|
|
.file = b.path(tracy_path ++ "/TracyClient.cpp"),
|
|
.flags = &[_][]const u8{
|
|
"-DTRACY_ENABLE",
|
|
"-DTRACY_NO_EXIT",
|
|
// 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",
|
|
},
|
|
});
|
|
|
|
if (opts.target.result.os.tag == .windows) {
|
|
mod.linkSystemLibrary("Advapi32", .{});
|
|
mod.linkSystemLibrary("User32", .{});
|
|
mod.linkSystemLibrary("Ws2_32", .{});
|
|
mod.linkSystemLibrary("DbgHelp", .{});
|
|
}
|
|
}
|
|
|
|
const build_opts = b.addOptions();
|
|
build_opts.addOption(bool, "tracy_enabled", tracy_enabled);
|
|
mod.addOptions("build_options", build_opts);
|
|
|
|
// ========== tests =============
|
|
const test_step = b.step("test", "run unit tests for tracy");
|
|
const tests = b.addTest(.{
|
|
.root_module = b.createModule(.{
|
|
.target = opts.target,
|
|
.optimize = opts.optimize,
|
|
.root_source_file = b.path("tracy_test.zig"),
|
|
}),
|
|
});
|
|
tests.root_module.addImport("tracy", mod);
|
|
const runArtifact = b.addRunArtifact(tests);
|
|
test_step.dependOn(&runArtifact.step);
|
|
}
|