Archived
1
0
Fork 0

gnu: imgui: Add support for fontconfig and the C++ standard library.

* gnu/packages/toolkits.scm (imgui)[source]: Streamline snippet.
[arguments]: Use gexps.
[phases]{build}: Add include directive to fonconfig headers.  Also build the
C++ sources found under the "misc" directory.
{install}: Install headers found under the "misc" directory.
[inputs]: Add fontconfig.
This commit is contained in:
Maxim Cournoyer 2022-03-21 15:10:54 -04:00
parent 249e84943e
commit 7f981c53df
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -19,8 +19,10 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages toolkits) (define-module (gnu packages toolkits)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages gl) #:use-module (gnu packages gl)
#:use-module (gnu packages sdl) #:use-module (gnu packages sdl)
#:use-module (guix gexp)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix utils) #:use-module (guix utils)
@ -42,29 +44,30 @@
"10qil22s5qak3as41787iz273sibpq1bq66bakgn7yvhj5fym6hz")) "10qil22s5qak3as41787iz273sibpq1bq66bakgn7yvhj5fym6hz"))
(modules '((guix build utils))) (modules '((guix build utils)))
(snippet (snippet
'(begin ;; Remove bundled fonts.
;; Remove bundled fonts. '(delete-file-recursively "misc/fonts"))))
(delete-file-recursively "misc/fonts")))))
(outputs '("out" "doc")) (outputs '("out" "doc"))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:tests? #f ;no test suite (list
#:modules ((guix build gnu-build-system) #:tests? #f ;no test suite
#:modules '((guix build gnu-build-system)
(guix build utils) (guix build utils)
(ice-9 ftw) (ice-9 ftw)
(srfi srfi-26)) (srfi srfi-26))
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'adjust-includes (add-after 'unpack 'adjust-includes
(lambda _ (lambda _
(substitute* (find-files "." "(\\.cpp|\\.mm)$") (substitute* (find-files "." "(\\.cpp|\\.mm)$")
(("#include <SDL") (("#include <SDL")
"#include <SDL2/SDL")))) "#include <SDL2/SDL"))))
(delete 'configure) (delete 'configure)
(replace 'build (replace 'build
(lambda _ (lambda* (#:key inputs #:allow-other-keys)
;; Build main library. ;; Build main library.
(invoke ,(cc-for-target) "-I" (getcwd) (apply invoke #$(cc-for-target) "-I" (getcwd)
"-I" (search-input-directory inputs "include/freetype2")
"-g" "-O2" "-fPIC" "-shared" "-g" "-O2" "-fPIC" "-shared"
"-lGL" "-lSDL2" "-lglfw" "-lGL" "-lSDL2" "-lglfw"
"-o" "libimgui.so" "-o" "libimgui.so"
@ -76,30 +79,38 @@
"backends/imgui_impl_glfw.cpp" "backends/imgui_impl_glfw.cpp"
"backends/imgui_impl_sdl.cpp" "backends/imgui_impl_sdl.cpp"
"backends/imgui_impl_opengl2.cpp" "backends/imgui_impl_opengl2.cpp"
"backends/imgui_impl_opengl3.cpp"))) "backends/imgui_impl_opengl3.cpp"
(replace 'install ;; Include wrappers for C++ standard library (STL) and
(lambda* (#:key outputs #:allow-other-keys) ;; fontconfig.
(let* ((out (assoc-ref outputs "out")) (find-files "misc" "\\.cpp$"))))
(doc (assoc-ref outputs "doc")) (replace 'install
(header? (cut string-suffix? ".h" <>)) (lambda* (#:key outputs #:allow-other-keys)
(imgui-headers (scandir "." header?)) (let* ((out (assoc-ref outputs "out"))
(backend-headers (find-files (doc (assoc-ref outputs "doc"))
"backends" (header? (cut string-suffix? ".h" <>))
"(glfw|opengl|sdl|vulkan).*\\.h$"))) (imgui-headers (scandir "." header?))
(install-file "libimgui.so" (string-append out "/lib")) (backend-headers (find-files
;; Install headers. "backends"
(for-each (lambda (f) "(glfw|opengl|sdl|vulkan).*\\.h$"))
(install-file f (string-append out "/include/imgui"))) (misc-headers (find-files "misc" "\\.h$")))
imgui-headers) (install-file "libimgui.so" (string-append out "/lib"))
(for-each (lambda (f) ;; Install headers.
(install-file f (string-append (for-each (lambda (f)
out "/include/imgui/backends"))) (install-file f (string-append out "/include/imgui")))
backend-headers) imgui-headers)
;; Install examples. (for-each (lambda (f)
(copy-recursively (install-file f (string-append
"examples" (string-append out "/include/imgui/backends")))
doc "/share/imgui/examples")))))))) backend-headers)
(inputs (list glfw mesa sdl2)) (for-each (lambda (f)
(install-file f (string-append
out "/include/imgui/" (dirname f))))
misc-headers)
;; Install examples.
(copy-recursively
"examples" (string-append
doc "/share/imgui/examples"))))))))
(inputs (list fontconfig glfw mesa sdl2))
(home-page "https://github.com/ocornut/imgui") (home-page "https://github.com/ocornut/imgui")
(synopsis "Immediate-mode C++ GUI library with minimal dependencies") (synopsis "Immediate-mode C++ GUI library with minimal dependencies")
(description "@code{dear imgui} (also know as ImGui) is a graphical user (description "@code{dear imgui} (also know as ImGui) is a graphical user