Subject: [bug#65106] [PATCH] gnu: Add tracy.

From: dan <[email-masked]>
Date: Sun, 6 Aug 2023 13:40:10 +0800

---
 gnu/packages/profiling.scm | 48 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/profiling.scm b/gnu/packages/profiling.scm
index 8a1c609669..799b333162 100644
--- a/gnu/packages/profiling.scm
+++ b/gnu/packages/profiling.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017 Dave Love <[email-masked]>
 ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2022 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2023 dan <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,6 +22,7 @@
 (define-module (gnu packages profiling)
   #:use-module (guix packages)
   #:use-module (guix gexp)
+  #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:) ; avoid zlib, expat clashes
   #:use-module (guix download)
   #:use-module (guix utils)
@@ -31,17 +33,20 @@ (define-module (gnu packages profiling)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
+  #:use-module (gnu packages engineering)
   #:use-module (gnu packages fabric-management)
   #:use-module (gnu packages flex)
+  #:use-module (gnu packages fontutils)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages gcc)
+  #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages libunwind)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages mpi)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages perl)
-  #:use-module (gnu packages perl)
+  #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
   #:use-module (gnu packages qt))
 
@@ -389,3 +394,44 @@ (define (make-scorep mpi)
     (license license:cpl1.0)))
 
 (define-public scorep-openmpi (make-scorep openmpi))
+
+(define-public tracy
+  (package
+    (name "tracy")
+    (version "0.9.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/wolfpld/tracy.git")
+                    (commit (string-append "v" version))))
+              (sha256
+               (base32
+                "1znw1r1c4vrb9vrsr08gcwynpjda8xxmb3923yykpymw2hsm0n9b"))
+              (file-name (git-file-name "tracy" version))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:tests? #f ;no test for the profiler
+           #:make-flags #~(list "LEGACY=1"
+                                (string-append "CC="
+                                               #$(cc-for-target)))
+           #:phases #~(modify-phases %standard-phases
+                        (replace 'configure
+                          (lambda _
+                            (chdir "profiler/build/unix")))
+                        (replace 'install
+                          (lambda _
+                            (let ((out (string-append #$output "/bin/tracy"))
+                                  (bin (string-append #$output "/bin")))
+                              (mkdir-p bin)
+                              (copy-file "Tracy-release" out)
+                              (wrap-program out
+                                `("LD_LIBRARY_PATH" ":" =
+                                  (,(string-append #$mesa "/lib"))))))))))
+    (inputs (list capstone dbus freetype glfw))
+    (native-inputs (list pkg-config))
+    (home-page "https://github.com/wolfpld/tracy")
+    (synopsis "Frame profiler")
+    (description
+     "A real time, nanosecond resolution, remote telemetry, hybrid frame and
+sampling profiler for games and other applications.")
+    (license license:bsd-3)))

base-commit: c4b9f726e3a1889b92a4b14a2af1c25f10798469
-- 
2.41.0