From b70983a0e4c17f4be05d25449c5ddca04fb901a5 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 17 Sep 2024 20:50:09 -0400 Subject: [PATCH] Build arguments for Tracy --- .vscode/settings.json | 5 +++++ project.hxp | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 227cb94ec..af5986fbf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -96,6 +96,11 @@ "target": "windows", "args": ["-debug", "-DFEATURE_DEBUG_FUNCTIONS"] }, + { + "label": "Windows / Debug (Tracy)", + "target": "windows", + "args": ["-debug", "-DFEATURE_DEBUG_TRACY", "-DFEATURE_DEBUG_FUNCTIONS"] + }, { "label": "Linux / Debug", "target": "linux", diff --git a/project.hxp b/project.hxp index 1193a9cd4..934cc1d2d 100644 --- a/project.hxp +++ b/project.hxp @@ -149,6 +149,14 @@ class Project extends HXProject { */ static final FEATURE_DEBUG_FUNCTIONS:FeatureFlag = "FEATURE_DEBUG_FUNCTIONS"; + /** + * `-DFEATURE_DEBUG_TRACY` + * If this flag is enabled, the game will have the necessary hooks for the Tracy profiler. + * Only enable this if you're using the correct fork of Haxe to support this. + * @see https://github.com/HaxeFoundation/hxcpp/pull/1153 + */ + static final FEATURE_DEBUG_TRACY:FeatureFlag = "FEATURE_DEBUG_TRACY"; + /** * `-DFEATURE_DISCORD_RPC` * If this flag is enabled, the game will enable the Discord Remote Procedure Call library. @@ -516,6 +524,16 @@ class Project extends HXProject { // Cleaner looking compiler errors. setHaxedef("message.reporting", "pretty"); + + if (FEATURE_DEBUG_TRACY.isEnabled(this)) { + setHaxedef("HXCPP_TELEMETRY"); // Enable telemetry + setHaxedef("HXCPP_TRACY"); // Enable Tracy telemetry + setHaxedef("HXCPP_TRACY_MEMORY"); // Track memory allocations + setHaxedef("HXCPP_TRACY_ON_DEMAND"); // Only collect telemetry when Tracy is open and reachable + // setHaxedef("HXCPP_TRACY_INCLUDE_CALLSTACKS"); // Inspect callstacks per zone, inflating telemetry data + + setHaxedef("absolute-paths"); // Fix source locations so Tracy can see them + } } /**