toolkits.scm 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  3. ;;; Copyright © 2020, 2022 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.89.4")
  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. "1j79gsg9i969slygrwm0dp5mkzagglawxxagjpi3009wyp6lj6l8"))
  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)
  68. ;; This option is necessary at least for OpenBoardView,
  69. ;; otherwise it would fail with the "Too many vertices in
  70. ;; ImDrawList using 16-bit indices".
  71. "-DImDrawIdx=unsigned int"
  72. "-I" (getcwd)
  73. "-I" (search-input-directory inputs "include/freetype2")
  74. "-g" "-O2" "-fPIC" "-shared"
  75. "-lGL" "-lSDL2" "-lglfw"
  76. "-o" "libimgui.so"
  77. "imgui.cpp"
  78. "imgui_draw.cpp"
  79. "imgui_tables.cpp"
  80. "imgui_widgets.cpp"
  81. ;; Include the supported backends.
  82. "backends/imgui_impl_glfw.cpp"
  83. (if (file-exists? "backends/imgui_impl_sdl2.cpp")
  84. "backends/imgui_impl_sdl2.cpp"
  85. "backends/imgui_impl_sdl.cpp")
  86. "backends/imgui_impl_opengl2.cpp"
  87. "backends/imgui_impl_opengl3.cpp"
  88. ;; Include wrappers for C++ standard library (STL) and
  89. ;; fontconfig.
  90. (find-files "misc" "\\.cpp$"))))
  91. (replace 'install
  92. (lambda _
  93. (let* ((header? (cut string-suffix? ".h" <>))
  94. (imgui-headers (scandir "." header?))
  95. (backend-headers (find-files
  96. "backends"
  97. "(glfw|opengl|sdl|vulkan).*\\.h$"))
  98. (misc-headers (find-files "misc" "\\.h$")))
  99. (install-file "libimgui.so" (string-append #$output "/lib"))
  100. ;; Install headers.
  101. (for-each (lambda (f)
  102. (install-file f (string-append #$output
  103. "/include/imgui")))
  104. imgui-headers)
  105. (for-each (lambda (f)
  106. (install-file f (string-append
  107. #$output
  108. "/include/imgui/backends")))
  109. backend-headers)
  110. (for-each (lambda (f)
  111. (install-file f (string-append #$output
  112. "/include/imgui/"
  113. (dirname f))))
  114. misc-headers)
  115. ;; Install examples.
  116. (copy-recursively "examples"
  117. (string-append #$output:doc
  118. "/share/imgui/examples"))))))))
  119. (inputs (list fontconfig glfw mesa sdl2))
  120. (home-page "https://github.com/ocornut/imgui")
  121. (synopsis "Immediate-mode C++ GUI library with minimal dependencies")
  122. (description "@code{dear imgui} (also know as ImGui) is a graphical user
  123. interface library for C++. It creates optimized vertex buffers that you can
  124. render anytime in your 3D-pipeline-enabled application. It's fast, portable,
  125. renderer-agnostic, and self-contained, without external dependencies.
  126. ImGui is aimed at content creation, visualization, and debugging tools as
  127. opposed to average end-user interfaces. Hence it favors simplicity and
  128. productivity but lacks certain features often found in higher-level libraries.
  129. It is particularly suited to integration in game engine tooling, real-time 3D
  130. applications, full-screen applications, and embedded platforms without
  131. standard operating system features.")
  132. (license license:expat)))
  133. (define-public imgui-1.87
  134. (package
  135. (inherit imgui)
  136. (name "imgui")
  137. (version "1.87")
  138. (source (origin
  139. (inherit (package-source imgui))
  140. (method git-fetch)
  141. (uri (git-reference
  142. (url "https://github.com/ocornut/imgui")
  143. (commit (string-append "v" version))))
  144. (file-name (git-file-name name version))
  145. (sha256
  146. (base32
  147. "10qil22s5qak3as41787iz273sibpq1bq66bakgn7yvhj5fym6hz"))))))
  148. (define-public imgui-1.86
  149. (package
  150. (inherit imgui)
  151. (name "imgui")
  152. (version "1.86")
  153. (source (origin
  154. (inherit (package-source imgui))
  155. (method git-fetch)
  156. (uri (git-reference
  157. (url "https://github.com/ocornut/imgui")
  158. (commit (string-append "v" version))))
  159. (file-name (git-file-name name version))
  160. (sha256
  161. (base32
  162. "02a7b05zrka20jhzag2jb4jl624i1m456bsv69jb9zgys2p9dv1n"))))))