Subject: [PATCH v2 2/2] gnu: Add tracy.

From: dan <[email-masked]>
Date: Mon, 25 Sep 2023 01:14:00 +0800

* gnu/packages/profiling.scm (tracy): New variable.
---
 gnu/packages/profiling.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/packages/profiling.scm b/gnu/packages/profiling.scm
index af79488c30..5f5b4b07d0 100644
--- a/gnu/packages/profiling.scm
+++ b/gnu/packages/profiling.scm
@@ -438,3 +438,31 @@ (define-public tracy-wayland
      "A real time, nanosecond resolution, remote telemetry, hybrid frame and
 sampling profiler for games and other applications.")
     (license license:bsd-3)))
+
+(define-public tracy
+  (package
+    (inherit tracy-wayland)
+    (name "tracy")
+    (inputs (modify-inputs (package-inputs tracy-wayland)
+              (delete "libxkbcommon" "wayland")
+              (prepend glfw)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments tracy-wayland)
+       ((#:make-flags flags
+         #~'())
+        #~(append #$flags
+                  ;; The LEGACY flag indicate we want to build tracy with glfw
+                  (list "LEGACY=1")))
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            ;; Tracy depends on glfw to load libGL.so, but glfw doesn't have
+            ;; mesa in its rpath.  Thus, we need to manually modify tracy's
+            ;; LD_LIBRARY_PATH.
+            (add-after 'install 'wrap-program
+              (lambda _
+                (let ((out (string-append #$output "/bin/tracy"))
+                      (mesa (string-append #$(this-package-input "mesa")
+                                           "/lib")))
+                  (wrap-program out
+                    `("LD_LIBRARY_PATH" ":" =
+                      (,mesa))))))))))))
-- 
2.41.0