toolkits.scm 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  3. ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  4. ;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. (define-module (gnu packages toolkits)
  21. #:use-module (gnu packages fontutils)
  22. #:use-module (gnu packages gl)
  23. #:use-module (gnu packages sdl)
  24. #:use-module (guix gexp)
  25. #:use-module ((guix licenses) #:prefix license:)
  26. #:use-module (guix packages)
  27. #:use-module (guix utils)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (guix git-download))
  30. (define-public imgui
  31. (package
  32. (name "imgui")
  33. (version "1.87")
  34. (source (origin
  35. (method git-fetch)
  36. (uri (git-reference
  37. (url "https://github.com/ocornut/imgui")
  38. (commit (string-append "v" version))))
  39. (file-name (git-file-name name version))
  40. (sha256
  41. (base32
  42. "10qil22s5qak3as41787iz273sibpq1bq66bakgn7yvhj5fym6hz"))
  43. (modules '((guix build utils)))
  44. (snippet
  45. ;; Remove bundled fonts.
  46. '(delete-file-recursively "misc/fonts"))))
  47. (outputs '("out" "doc"))
  48. (build-system gnu-build-system)
  49. (arguments
  50. (list
  51. #:tests? #f ;no test suite
  52. #:modules '((guix build gnu-build-system)
  53. (guix build utils)
  54. (ice-9 ftw)
  55. (srfi srfi-26))
  56. #:phases
  57. #~(modify-phases %standard-phases
  58. (add-after 'unpack 'adjust-includes
  59. (lambda _
  60. (substitute* (find-files "." "(\\.cpp|\\.mm)$")
  61. (("#include <SDL")
  62. "#include <SDL2/SDL"))))
  63. (delete 'configure)
  64. (replace 'build
  65. (lambda* (#:key inputs #:allow-other-keys)
  66. ;; Build main library.
  67. (apply invoke #$(cc-for-target) "-I" (getcwd)
  68. "-I" (search-input-directory inputs "include/freetype2")
  69. "-g" "-O2" "-fPIC" "-shared"
  70. "-lGL" "-lSDL2" "-lglfw"
  71. "-o" "libimgui.so"
  72. "imgui.cpp"
  73. "imgui_draw.cpp"
  74. "imgui_tables.cpp"
  75. "imgui_widgets.cpp"
  76. ;; Include the supported backends.
  77. "backends/imgui_impl_glfw.cpp"
  78. "backends/imgui_impl_sdl.cpp"
  79. "backends/imgui_impl_opengl2.cpp"
  80. "backends/imgui_impl_opengl3.cpp"
  81. ;; Include wrappers for C++ standard library (STL) and
  82. ;; fontconfig.
  83. (find-files "misc" "\\.cpp$"))))
  84. (replace 'install
  85. (lambda* (#:key outputs #:allow-other-keys)
  86. (let* ((out (assoc-ref outputs "out"))
  87. (doc (assoc-ref outputs "doc"))
  88. (header? (cut string-suffix? ".h" <>))
  89. (imgui-headers (scandir "." header?))
  90. (backend-headers (find-files
  91. "backends"
  92. "(glfw|opengl|sdl|vulkan).*\\.h$"))
  93. (misc-headers (find-files "misc" "\\.h$")))
  94. (install-file "libimgui.so" (string-append out "/lib"))
  95. ;; Install headers.
  96. (for-each (lambda (f)
  97. (install-file f (string-append out "/include/imgui")))
  98. imgui-headers)
  99. (for-each (lambda (f)
  100. (install-file f (string-append
  101. out "/include/imgui/backends")))
  102. backend-headers)
  103. (for-each (lambda (f)
  104. (install-file f (string-append
  105. out "/include/imgui/" (dirname f))))
  106. misc-headers)
  107. ;; Install examples.
  108. (copy-recursively
  109. "examples" (string-append
  110. doc "/share/imgui/examples"))))))))
  111. (inputs (list fontconfig glfw mesa sdl2))
  112. (home-page "https://github.com/ocornut/imgui")
  113. (synopsis "Immediate-mode C++ GUI library with minimal dependencies")
  114. (description "@code{dear imgui} (also know as ImGui) is a graphical user
  115. interface library for C++. It creates optimized vertex buffers that you can
  116. render anytime in your 3D-pipeline-enabled application. It's fast, portable,
  117. renderer-agnostic, and self-contained, without external dependencies.
  118. ImGui is aimed at content creation, visualization, and debugging tools as
  119. opposed to average end-user interfaces. Hence it favors simplicity and
  120. productivity but lacks certain features often found in higher-level libraries.
  121. It is particularly suited to integration in game engine tooling, real-time 3D
  122. applications, full-screen applications, and embedded platforms without
  123. standard operating system features.")
  124. (license license:expat)))
  125. (define-public imgui-1.86
  126. (package
  127. (inherit imgui)
  128. (name "imgui")
  129. (version "1.86")
  130. (source (origin
  131. (inherit (package-source imgui))
  132. (method git-fetch)
  133. (uri (git-reference
  134. (url "https://github.com/ocornut/imgui")
  135. (commit (string-append "v" version))))
  136. (file-name (git-file-name name version))
  137. (sha256
  138. (base32
  139. "02a7b05zrka20jhzag2jb4jl624i1m456bsv69jb9zgys2p9dv1n"))))))