mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
pkg/tracy
This commit is contained in:
13
build.zig
13
build.zig
@ -15,7 +15,6 @@ const XCFrameworkStep = @import("src/build/XCFrameworkStep.zig");
|
|||||||
const Version = @import("src/build/Version.zig");
|
const Version = @import("src/build/Version.zig");
|
||||||
|
|
||||||
const glfw = @import("vendor/mach-glfw/build.zig");
|
const glfw = @import("vendor/mach-glfw/build.zig");
|
||||||
const tracylib = @import("pkg/tracy/build.zig");
|
|
||||||
const system_sdk = @import("vendor/mach-glfw/system_sdk.zig");
|
const system_sdk = @import("vendor/mach-glfw/system_sdk.zig");
|
||||||
|
|
||||||
// Do a comptime Zig version requirement. The required Zig version is
|
// Do a comptime Zig version requirement. The required Zig version is
|
||||||
@ -672,6 +671,10 @@ fn addDeps(
|
|||||||
.target = step.target,
|
.target = step.target,
|
||||||
.optimize = step.optimize,
|
.optimize = step.optimize,
|
||||||
});
|
});
|
||||||
|
const tracy_dep = b.dependency("tracy", .{
|
||||||
|
.target = step.target,
|
||||||
|
.optimize = step.optimize,
|
||||||
|
});
|
||||||
const zlib_dep = b.dependency("zlib", .{
|
const zlib_dep = b.dependency("zlib", .{
|
||||||
.target = step.target,
|
.target = step.target,
|
||||||
.optimize = step.optimize,
|
.optimize = step.optimize,
|
||||||
@ -691,7 +694,7 @@ fn addDeps(
|
|||||||
if (step.target.getCpuArch() == .wasm32) {
|
if (step.target.getCpuArch() == .wasm32) {
|
||||||
// We link this package but its a no-op since Tracy
|
// We link this package but its a no-op since Tracy
|
||||||
// never actually WORKS with wasm.
|
// never actually WORKS with wasm.
|
||||||
step.addModule("tracy", tracylib.module(b));
|
step.addModule("tracy", tracy_dep.module("tracy"));
|
||||||
step.addModule("utf8proc", utf8proc_dep.module("utf8proc"));
|
step.addModule("utf8proc", utf8proc_dep.module("utf8proc"));
|
||||||
step.addModule("zig-js", js_dep.module("zig-js"));
|
step.addModule("zig-js", js_dep.module("zig-js"));
|
||||||
|
|
||||||
@ -743,10 +746,10 @@ fn addDeps(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tracy
|
// Tracy
|
||||||
step.addModule("tracy", tracylib.module(b));
|
step.addModule("tracy", tracy_dep.module("tracy"));
|
||||||
if (tracy) {
|
if (tracy) {
|
||||||
var tracy_step = try tracylib.link(b, step);
|
step.linkLibrary(tracy_dep.artifact("tracy"));
|
||||||
system_sdk.include(b, tracy_step, .{});
|
try static_libs.append(tracy_dep.artifact("tracy").getEmittedBin());
|
||||||
}
|
}
|
||||||
|
|
||||||
// utf8proc
|
// utf8proc
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
.libpng = .{ .path = "./pkg/libpng" },
|
.libpng = .{ .path = "./pkg/libpng" },
|
||||||
.macos = .{ .path = "./pkg/macos" },
|
.macos = .{ .path = "./pkg/macos" },
|
||||||
.pixman = .{ .path = "./pkg/pixman" },
|
.pixman = .{ .path = "./pkg/pixman" },
|
||||||
|
.tracy = .{ .path = "./pkg/tracy" },
|
||||||
.utf8proc = .{ .path = "./pkg/utf8proc" },
|
.utf8proc = .{ .path = "./pkg/utf8proc" },
|
||||||
.zlib = .{ .path = "./pkg/zlib" },
|
.zlib = .{ .path = "./pkg/zlib" },
|
||||||
},
|
},
|
||||||
|
@ -1,68 +1,91 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
/// Directories with our includes.
|
pub fn build(b: *std.Build) !void {
|
||||||
const root = thisDir() ++ "../../../vendor/tracy/";
|
const target = b.standardTargetOptions(.{});
|
||||||
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
pub fn module(b: *std.Build) *std.build.Module {
|
_ = b.addModule("tracy", .{ .source_file = .{ .path = "tracy.zig" } });
|
||||||
return b.createModule(.{
|
|
||||||
.source_file = .{ .path = (comptime thisDir()) ++ "/tracy.zig" },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn thisDir() []const u8 {
|
const upstream = b.dependency("tracy", .{});
|
||||||
return std.fs.path.dirname(@src().file) orelse ".";
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn link(b: *std.Build, step: *std.build.LibExeObjStep) !*std.build.LibExeObjStep {
|
|
||||||
const tracy = try buildTracy(b, step);
|
|
||||||
step.linkLibrary(tracy);
|
|
||||||
step.addIncludePath(.{ .path = root });
|
|
||||||
return tracy;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn buildTracy(
|
|
||||||
b: *std.Build,
|
|
||||||
step: *std.build.LibExeObjStep,
|
|
||||||
) !*std.build.LibExeObjStep {
|
|
||||||
const target = step.target;
|
|
||||||
const lib = b.addStaticLibrary(.{
|
const lib = b.addStaticLibrary(.{
|
||||||
.name = "tracy",
|
.name = "tracy",
|
||||||
.target = step.target,
|
.target = target,
|
||||||
.optimize = step.optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
|
||||||
defer flags.deinit();
|
|
||||||
|
|
||||||
try flags.appendSlice(&.{
|
|
||||||
"-DTRACY_ENABLE",
|
|
||||||
"-fno-sanitize=undefined",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (target.isWindows()) {
|
|
||||||
try flags.appendSlice(&.{
|
|
||||||
"-D_WIN32_WINNT=0x601",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
lib.addIncludePath(.{ .path = root });
|
|
||||||
lib.addCSourceFile(.{
|
|
||||||
.file = .{ .path = try std.fs.path.join(
|
|
||||||
b.allocator,
|
|
||||||
&.{ root, "TracyClient.cpp" },
|
|
||||||
) },
|
|
||||||
.flags = flags.items,
|
|
||||||
});
|
|
||||||
|
|
||||||
lib.linkLibC();
|
lib.linkLibC();
|
||||||
lib.linkSystemLibrary("c++");
|
lib.linkLibCpp();
|
||||||
|
if (target.isWindows()) {
|
||||||
if (lib.target.isWindows()) {
|
|
||||||
lib.linkSystemLibrary("Advapi32");
|
lib.linkSystemLibrary("Advapi32");
|
||||||
lib.linkSystemLibrary("User32");
|
lib.linkSystemLibrary("User32");
|
||||||
lib.linkSystemLibrary("Ws2_32");
|
lib.linkSystemLibrary("Ws2_32");
|
||||||
lib.linkSystemLibrary("DbgHelp");
|
lib.linkSystemLibrary("DbgHelp");
|
||||||
}
|
}
|
||||||
|
|
||||||
return lib;
|
lib.addIncludePath(upstream.path(""));
|
||||||
|
|
||||||
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
|
defer flags.deinit();
|
||||||
|
try flags.appendSlice(&.{
|
||||||
|
"-DTRACY_ENABLE",
|
||||||
|
"-fno-sanitize=undefined",
|
||||||
|
});
|
||||||
|
if (target.isWindows()) {
|
||||||
|
try flags.appendSlice(&.{
|
||||||
|
"-D_WIN32_WINNT=0x601",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
lib.addCSourceFile(.{
|
||||||
|
.file = upstream.path("TracyClient.cpp"),
|
||||||
|
.flags = flags.items,
|
||||||
|
});
|
||||||
|
|
||||||
|
lib.installHeadersDirectoryOptions(.{
|
||||||
|
.source_dir = upstream.path(""),
|
||||||
|
.install_dir = .header,
|
||||||
|
.install_subdir = "",
|
||||||
|
.include_extensions = &.{ ".h", ".hpp" },
|
||||||
|
});
|
||||||
|
|
||||||
|
b.installArtifact(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const headers = &.{
|
||||||
|
"TracyC.h",
|
||||||
|
"TracyOpenGL.hpp",
|
||||||
|
"Tracy.hpp",
|
||||||
|
"TracyD3D11.hpp",
|
||||||
|
"TracyD3D12.hpp",
|
||||||
|
"TracyOpenCL.hpp",
|
||||||
|
"TracyVulkan.hpp",
|
||||||
|
"client/TracyCallstack.h",
|
||||||
|
"client/TracyScoped.hpp",
|
||||||
|
"client/TracyStringHelpers.hpp",
|
||||||
|
"client/TracySysTrace.hpp",
|
||||||
|
"client/TracyDxt1.hpp",
|
||||||
|
"client/TracyRingBuffer.hpp",
|
||||||
|
"client/tracy_rpmalloc.hpp",
|
||||||
|
"client/TracyDebug.hpp",
|
||||||
|
"client/TracyLock.hpp",
|
||||||
|
"client/TracyThread.hpp",
|
||||||
|
"client/TracyArmCpuTable.hpp",
|
||||||
|
"client/TracyProfiler.hpp",
|
||||||
|
"client/TracyCallstack.hpp",
|
||||||
|
"client/TracySysTime.hpp",
|
||||||
|
"client/TracyFastVector.hpp",
|
||||||
|
"common/TracyApi.h",
|
||||||
|
"common/TracyYield.hpp",
|
||||||
|
"common/tracy_lz4hc.hpp",
|
||||||
|
"common/TracySystem.hpp",
|
||||||
|
"common/TracyProtocol.hpp",
|
||||||
|
"common/TracyQueue.hpp",
|
||||||
|
"common/TracyUwp.hpp",
|
||||||
|
"common/TracyAlloc.hpp",
|
||||||
|
"common/TracyAlign.hpp",
|
||||||
|
"common/TracyForceInline.hpp",
|
||||||
|
"common/TracyColor.hpp",
|
||||||
|
"common/tracy_lz4.hpp",
|
||||||
|
"common/TracyStackFrames.hpp",
|
||||||
|
"common/TracySocket.hpp",
|
||||||
|
"common/TracyMutex.hpp",
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user