diff mbox series

[bug#53015,v3] Add mangohud.

Message ID An66NkD40n-mjbCw27e48uZ8CpGvOlLuIuETg6dbT5M5LJ4dytLBBpnmw_7hx5MEfIsJRcE2KSIP4O5EcapPOjBJQUbh5j6_rif9duxCnlY=@protonmail.com
State Accepted
Headers show
Series [bug#53015,v3] Add mangohud. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

John Kehayias Feb. 27, 2022, 1:14 a.m. UTC
>
> Attached is an update to this patch series, reduced to just one patch. This relies on the hwdata package added in https://issues.guix.gnu.org/54069#2 and the update to imgui I sent in https://issues.guix.gnu.org/54132
>
> With that, mangohud just uses imgui-1.86 (the newer version has a breaking change). The modifications to the meson.build is handled in a build phase substitute* rather than a patch, as it needs the imgui location.
>
> I've checked this builds and works. Let me know if any other modifications are needed, other than the hwdata and imgui fixes referenced.
>

Attached is a revised patch to use the new hwdata package with inputs, so the correct input is now `(,hwdata "pci"). I checked that it applied and built on master.

John

Comments

Maxim Cournoyer Feb. 27, 2022, 2:31 a.m. UTC | #1
Hi John,

John Kehayias <john.kehayias@protonmail.com> writes:

>>
>> Attached is an update to this patch series, reduced to just one
>> patch. This relies on the hwdata package added in
>> https://issues.guix.gnu.org/54069#2 and the update to imgui I sent
>> in https://issues.guix.gnu.org/54132
>>
>> With that, mangohud just uses imgui-1.86 (the newer version has a
>> breaking change). The modifications to the meson.build is handled in
>> a build phase substitute* rather than a patch, as it needs the imgui
>> location.
>>
>> I've checked this builds and works. Let me know if any other
>> modifications are needed, other than the hwdata and imgui fixes
>> referenced.
>>
>
> Attached is a revised patch to use the new hwdata package with inputs,
> so the correct input is now `(,hwdata "pci"). I checked that it
> applied and built on master.
>
> John

I took the freedom to make some cosmetic adjustments:

1. ordering of inputs
2. ordering of fields (match the conventions, such as the 'home-page'
field appearing before the synopsis)
3. indent some longer lines so they fit under 80 columns
4. normalize paths passed to search-input-file by stripping lead '/'.

like so:

--8<---------------cut here---------------start------------->8---
modified   gnu/packages/graphics.scm
@@ -890,8 +890,7 @@ (define-public mangohud
               "-Dwith_xnvctrl=disabled"
               "-Dappend_libdir_mangohud=false"
               (string-append "-Dvulkan_datadir="
-                             #$(this-package-input "vulkan-headers")
-                             "/share"))
+                             #$(this-package-input "vulkan-headers") "/share"))
       #:phases
       #~(modify-phases %standard-phases
           ;; Mangohud tries to build the imgui library as a meson submodule,
@@ -902,9 +901,10 @@ (define-public mangohud
                 (("dearimgui_sp = .*")
                  "")
                 (("dearimgui_sp.get_variable\\('imgui_dep'\\)")
-                 (string-append "declare_dependency(dependencies: "
-                                "cpp.find_library('imgui'), include_directories: '"
-                                #$(this-package-input "imgui") "/include/imgui')")))))
+                 (string-append
+                  "declare_dependency(dependencies: "
+                  "cpp.find_library('imgui'), include_directories: '"
+                  #$(this-package-input "imgui") "/include/imgui')")))))
           (add-after 'unpack 'patch-paths
             (lambda* (#:key inputs #:allow-other-keys)
               (substitute* "src/meson.build"
@@ -912,15 +912,15 @@ (define-public mangohud
                  "lib"))
               (substitute* "src/loaders/loader_libdrm.cpp"
                 (("libdrm.so.2")
-                 (search-input-file inputs "/lib/libdrm.so.2"))
+                 (search-input-file inputs "lib/libdrm.so.2"))
                 (("libdrm_amdgpu.so.1")
-                 (search-input-file inputs "/lib/libdrm_amdgpu.so.1")))
+                 (search-input-file inputs "lib/libdrm_amdgpu.so.1")))
               (substitute* "src/overlay.cpp"
                 (("glxinfo")
-                 (search-input-file inputs "/bin/glxinfo")))
+                 (search-input-file inputs "bin/glxinfo")))
               (substitute* "src/loaders/loader_x11.cpp"
                 (("libX11.so.6")
-                 (search-input-file inputs "/lib/libX11.so.6")))
+                 (search-input-file inputs "lib/libX11.so.6")))
               (substitute* "src/pci_ids.cpp"
                 (("/usr/share/hwdata/pci.ids")
                  (search-input-file inputs "share/hwdata/pci.ids")))
@@ -932,21 +932,19 @@ (define-public mangohud
            glslang
            `(,hwdata "pci")
            imgui-1.86
-           mesa
-           mesa-utils
            libdrm
            libx11
+           mesa
+           mesa-utils
            python-mako
            spdlog
-           vulkan-loader
-           vulkan-headers))
-    (native-inputs
-     (list pkg-config python))
-    (synopsis "Vulkan and OpenGL overlay for monitoring performance and hardware")
-    (description
-     "MangoHud is a Vulkan and OpenGL overlay for monitoring frames per second (FPS),
-temperatures, CPU/GPU load and more.")
+           vulkan-headers
+           vulkan-loader))
+    (native-inputs (list pkg-config python))
     (home-page "https://github.com/flightlessmango/MangoHud/")
+    (synopsis "Vulkan and OpenGL overlay for monitoring performance and hardware")
+    (description "MangoHud is a Vulkan and OpenGL overlay for monitoring
+frames per second (FPS), temperatures, CPU/GPU load and more.")
     (license license:expat)))
--8<---------------cut here---------------end--------------->8---

And pushed 31ecd80db7.

Thank you!

Closing.

Maxim
John Kehayias Feb. 27, 2022, 4:31 a.m. UTC | #2
Hi Maxim,

------- Original Message -------

On Saturday, February 26th, 2022 at 9:31 PM, Maxim Cournoyer wrote:

> I took the freedom to make some cosmetic adjustments:
>
> 1. ordering of inputs
> 2. ordering of fields (match the conventions, such as the 'home-page'
> field appearing before the synopsis)
> 3. indent some longer lines so they fit under 80 columns
> 4. normalize paths passed to search-input-file by stripping lead '/'.
>

Thanks, will take note for the future. No excuse for not alphabetizing when I know I did it twice. Insert ashamed emoji.

>
> And pushed 31ecd80db7.
>
> Thank you!

Thank you! Very happy to finally have this in, along with the various other package changes along the way.

John
diff mbox series

Patch

From 73babfb8747916fb8bd0584cffb7fcd4a2c469c7 Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Wed, 23 Feb 2022 17:29:39 -0500
Subject: [PATCH] gnu: Add mangohud.

* gnu/packages/graphics.scm (mangohud): New variable.
---
 gnu/packages/graphics.scm | 86 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)

diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index 04f92e2b07..40ed72b323 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -28,6 +28,7 @@ 
 ;;; Copyright © 2021 Ekaitz Zarraga <ekaitz@elenq.tech>
 ;;; Copyright © 2021, 2022 Vinicius Monego <monego@posteo.net>
 ;;; Copyright © 2022 Michael Rohleder <mike@rohleder.de>
+;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -80,11 +81,13 @@  (define-module (gnu packages graphics)
   #:use-module (gnu packages kde-frameworks)
   #:use-module (gnu packages libusb)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages logging)
   #:use-module (gnu packages llvm)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages mp3)
   #:use-module (gnu packages multiprecision)
+  #:use-module (gnu packages pciutils)
   #:use-module (gnu packages pdf)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages photo)
@@ -117,6 +120,7 @@  (define-module (gnu packages graphics)
   #:use-module (guix build-system python)
   #:use-module (guix build-system qt)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix hg-download)
   #:use-module ((guix licenses) #:prefix license:)
@@ -863,6 +867,88 @@  (define-public alembic
 distills complex, animated scenes into a set of baked geometric results.")
     (license license:bsd-3)))
 
+(define-public mangohud
+  (package
+    (name "mangohud")
+    (version "0.6.6-1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/flightlessmango/MangoHud/")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0ka004wxkajmvs5vy60r4ckm7f169c61rrd46w6gywkaqf5yp1ab"))))
+    (build-system meson-build-system)
+    (arguments
+     (list
+      #:build-type "release"
+      #:configure-flags
+      #~(list "-Duse_system_vulkan=enabled"
+              "-Duse_system_spdlog=enabled"
+              "-Dwith_xnvctrl=disabled"
+              "-Dappend_libdir_mangohud=false"
+              (string-append "-Dvulkan_datadir="
+                             #$(this-package-input "vulkan-headers")
+                             "/share"))
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; Mangohud tries to build the imgui library as a meson submodule,
+          ;; so we change the dependency to the imgui input instead.
+          (add-after 'unpack 'unbundle-imgui
+            (lambda _
+              (substitute* "meson.build"
+                (("dearimgui_sp = .*")
+                 "")
+                (("dearimgui_sp.get_variable\\('imgui_dep'\\)")
+                 (string-append "declare_dependency(dependencies: "
+                                "cpp.find_library('imgui'), include_directories: '"
+                                #$(this-package-input "imgui") "/include/imgui')")))))
+          (add-after 'unpack 'patch-paths
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "src/meson.build"
+                (("\\\\\\$LIB")
+                 "lib"))
+              (substitute* "src/loaders/loader_libdrm.cpp"
+                (("libdrm.so.2")
+                 (search-input-file inputs "/lib/libdrm.so.2"))
+                (("libdrm_amdgpu.so.1")
+                 (search-input-file inputs "/lib/libdrm_amdgpu.so.1")))
+              (substitute* "src/overlay.cpp"
+                (("glxinfo")
+                 (search-input-file inputs "/bin/glxinfo")))
+              (substitute* "src/loaders/loader_x11.cpp"
+                (("libX11.so.6")
+                 (search-input-file inputs "/lib/libX11.so.6")))
+              (substitute* "src/pci_ids.cpp"
+                (("/usr/share/hwdata/pci.ids")
+                 (search-input-file inputs "share/hwdata/pci.ids")))
+              (substitute* "src/dbus.cpp"
+                (("libdbus-1.so.3")
+                 (search-input-file inputs "lib/libdbus-1.so.3"))))))))
+    (inputs
+     (list dbus
+           glslang
+           `(,hwdata "pci")
+           imgui-1.86
+           mesa
+           mesa-utils
+           libdrm
+           libx11
+           python-mako
+           spdlog
+           vulkan-loader
+           vulkan-headers))
+    (native-inputs
+     (list pkg-config python))
+    (synopsis "Vulkan and OpenGL overlay for monitoring performance and hardware")
+    (description
+     "MangoHud is a Vulkan and OpenGL overlay for monitoring frames per second (FPS),
+temperatures, CPU/GPU load and more.")
+    (home-page "https://github.com/flightlessmango/MangoHud/")
+    (license license:expat)))
+
 (define-public ogre
   (package
     (name "ogre")
-- 
2.34.0