diff mbox series

[bug#64213,v2,1/2] gnu: imgui: Use #:make-flags.

Message ID 878rc48ksm.fsf@protonmail.com
State New
Headers show
Series [bug#64213,v2,1/2] gnu: imgui: Use #:make-flags. | expand

Commit Message

John Kehayias June 28, 2023, 12:58 a.m. UTC
With some help from #guix, a better way was found: employ #:make-flags (even though there is no make here, use them the same way in the custom 'build phase). Now there are two patches: first adjusts imgui to use #:make-flags and the second fixes the issue with mangohud from imgui-1.86 by adjusting these flags.
diff mbox series

Patch

From 82f14241e45a4d56fdf26e7bc463407941ead4a7 Mon Sep 17 00:00:00 2001
Message-Id: <82f14241e45a4d56fdf26e7bc463407941ead4a7.1687913689.git.john.kehayias@protonmail.com>
From: John Kehayias <john.kehayias@protonmail.com>
Date: Tue, 27 Jun 2023 20:43:44 -0400
Subject: [PATCH 1/2] gnu: imgui: Use #:make-flags.

* gnu/packages/toolkits.scm (imgui)[arguments]: Add #:make-flags to replace
compiler arguments in the 'build phase.
---
 gnu/packages/toolkits.scm | 54 +++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/gnu/packages/toolkits.scm b/gnu/packages/toolkits.scm
index aee6c22e2d..1af10d83f4 100644
--- a/gnu/packages/toolkits.scm
+++ b/gnu/packages/toolkits.scm
@@ -1,7 +1,7 @@ 
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2020, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
-;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
+;;; Copyright © 2022, 2023 John Kehayias <john.kehayias@protonmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -55,6 +55,18 @@  (define-public imgui
                   (guix build utils)
                   (ice-9 ftw)
                   (srfi srfi-26))
+      ;; The build phase does not use make but we will use make-flags in a
+      ;; similar fashion to make inheritance for older imgui versions easier.
+      #:make-flags
+      ;; This first option is necessary at least for OpenBoardView, otherwise
+      ;; it would fail with the "Too many vertices in ImDrawList using 16-bit
+      ;; indices".
+      #~(list "-DImDrawIdx=unsigned int"
+              "-I" (string-append (getcwd) "/source")
+              "-I" (search-input-directory %build-inputs "include/freetype2")
+              "-g" "-O2" "-fPIC" "-shared"
+              "-lGL" "-lSDL2" "-lglfw"
+              "-o" "libimgui.so")
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'adjust-includes
@@ -64,32 +76,24 @@  (define-public imgui
                  "#include <SDL2/SDL"))))
           (delete 'configure)
           (replace 'build
-            (lambda* (#:key inputs #:allow-other-keys)
+            (lambda* (#:key make-flags #:allow-other-keys)
               ;; Build main library.
               (apply invoke #$(cc-for-target)
-                     ;; This option is necessary at least for OpenBoardView,
-                     ;; otherwise it would fail with the "Too many vertices in
-                     ;; ImDrawList using 16-bit indices".
-                     "-DImDrawIdx=unsigned int"
-                     "-I" (getcwd)
-                     "-I" (search-input-directory inputs "include/freetype2")
-                     "-g" "-O2" "-fPIC" "-shared"
-                     "-lGL" "-lSDL2" "-lglfw"
-                     "-o" "libimgui.so"
-                     "imgui.cpp"
-                     "imgui_draw.cpp"
-                     "imgui_tables.cpp"
-                     "imgui_widgets.cpp"
-                     ;; Include the supported backends.
-                     "backends/imgui_impl_glfw.cpp"
-                     (if (file-exists? "backends/imgui_impl_sdl2.cpp")
-                         "backends/imgui_impl_sdl2.cpp"
-                         "backends/imgui_impl_sdl.cpp")
-                     "backends/imgui_impl_opengl2.cpp"
-                     "backends/imgui_impl_opengl3.cpp"
-                     ;; Include wrappers for C++ standard library (STL) and
-                     ;; fontconfig.
-                     (find-files "misc" "\\.cpp$"))))
+                     (append make-flags
+                             `("imgui.cpp"
+                               "imgui_draw.cpp"
+                               "imgui_tables.cpp"
+                               "imgui_widgets.cpp"
+                               ;; Include the supported backends.
+                               "backends/imgui_impl_glfw.cpp"
+                               ,(if (file-exists? "backends/imgui_impl_sdl2.cpp")
+                                    "backends/imgui_impl_sdl2.cpp"
+                                    "backends/imgui_impl_sdl.cpp")
+                               "backends/imgui_impl_opengl2.cpp"
+                               "backends/imgui_impl_opengl3.cpp"
+                               ;; Include wrappers for C++ standard library (STL) and
+                               ;; fontconfig.
+                               ,@(find-files "misc" "\\.cpp$"))))))
           (replace 'install
             (lambda _
               (let* ((header? (cut string-suffix? ".h" <>))

base-commit: 63660f0febb4aa0d5260791c82dfde15c0df4c79
-- 
2.40.1