projects/guix·blob ruby-team · refs

324 lines · 13.5 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2025 Andreas Enge <[email protected]>
3;;; Copyright © 2020, 2022 Tobias Geerinckx-Rice <[email protected]>
4;;; Copyright © 2022 Andy Tai <[email protected]>
5;;; Copyright © 2022, 2023 John Kehayias <[email protected]>
6;;; Copyright © 2022, 2023 Maxim Cournoyer <[email protected]>
7;;; Copyright © 2023 Simon South <[email protected]>
8;;;
9;;; This file is part of GNU Guix.
10;;;
11;;; GNU Guix is free software; you can redistribute it and/or modify it
12;;; under the terms of the GNU General Public License as published by
13;;; the Free Software Foundation; either version 3 of the License, or (at
14;;; your option) any later version.
15;;;
16;;; GNU Guix is distributed in the hope that it will be useful, but
17;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;;; GNU General Public License for more details.
20;;;
21;;; You should have received a copy of the GNU General Public License
22;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24(define-module (gnu packages toolkits)
25 #:use-module (gnu packages autotools)
26 #:use-module (gnu packages compiler-tools)
27 #:use-module (gnu packages documentation)
28 #:use-module (gnu packages fontutils)
29 #:use-module (gnu packages gcc)
30 #:use-module (gnu packages gl)
31 #:use-module (gnu packages pkg-config)
32 #:use-module (gnu packages xorg)
33 #:use-module (gnu packages python-build)
34 #:use-module (gnu packages sdl)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system pyproject)
37 #:use-module (guix gexp)
38 #:use-module (guix git-download)
39 #:use-module ((guix licenses) #:prefix license:)
40 #:use-module (guix packages)
41 #:use-module (guix utils))
42
43(define-public imgui
44 (package
45 (name "imgui")
46 (version "1.92.2b")
47 (source (origin
48 (method git-fetch)
49 (uri (git-reference
50 (url "https://github.com/ocornut/imgui")
51 (commit (string-append "v" version))))
52 (file-name (git-file-name name version))
53 (sha256
54 (base32
55 "108dvbsqyf9am0f744z3ymgfppw1ad0amqkbwwwg2kqdm85dq1wv"))
56 (modules '((guix build utils)))
57 (snippet
58 ;; Remove bundled fonts.
59 #~(for-each delete-file
60 (find-files "misc/fonts" "\\.ttf")))))
61 (outputs '("out" "doc"))
62 (build-system gnu-build-system)
63 (arguments
64 (list
65 #:tests? #f ;no test suite
66 #:modules '((guix build gnu-build-system)
67 (guix build utils)
68 (ice-9 ftw)
69 (srfi srfi-26))
70 ;; The build phase does not use make but we will use make-flags in a
71 ;; similar fashion to make inheritance for older imgui versions easier.
72 #:make-flags
73 ;; This first option is necessary at least for OpenBoardView, otherwise
74 ;; it would fail with the "Too many vertices in ImDrawList using 16-bit
75 ;; indices".
76 #~(list "-DImDrawIdx=unsigned int"
77 "-DIMGUI_ENABLE_FREETYPE"
78 "-I" (string-append (getcwd) "/source")
79 "-I" (search-input-directory %build-inputs "include/freetype2")
80 "-g" "-O2" "-fPIC" "-shared"
81 "-lGL" "-lSDL2" "-lglfw"
82 "-o" "libimgui.so")
83 #:phases
84 #~(modify-phases %standard-phases
85 (add-after 'unpack 'adjust-includes
86 (lambda _
87 (substitute* (find-files "." "(\\.cpp|\\.mm)$")
88 (("#include <SDL")
89 "#include <SDL2/SDL"))))
90 (delete 'configure)
91 (replace 'build
92 (lambda* (#:key make-flags #:allow-other-keys)
93 ;; Build main library.
94 (apply invoke #$(cc-for-target)
95 (append make-flags
96 `("imgui.cpp"
97 "imgui_draw.cpp"
98 "imgui_tables.cpp"
99 "imgui_widgets.cpp"
100 ;; Include the supported backends.
101 "backends/imgui_impl_glfw.cpp"
102 ,(if (file-exists? "backends/imgui_impl_sdl2.cpp")
103 "backends/imgui_impl_sdl2.cpp"
104 "backends/imgui_impl_sdl.cpp")
105 "backends/imgui_impl_opengl2.cpp"
106 "backends/imgui_impl_opengl3.cpp"
107 ;; Include wrappers for C++ standard library (STL) and
108 ;; fontconfig.
109 ,@(find-files "misc" "\\.cpp$"))))))
110 (replace 'install
111 (lambda _
112 (let* ((header? (cut string-suffix? ".h" <>))
113 (imgui-headers (scandir "." header?))
114 (backend-headers (find-files
115 "backends"
116 "(glfw|opengl|sdl|vulkan).*\\.h$"))
117 (misc-headers (find-files "misc" "\\.h$")))
118 (install-file "libimgui.so" (string-append #$output "/lib"))
119 ;; Install headers.
120 (for-each (lambda (f)
121 (install-file f (string-append #$output
122 "/include/imgui")))
123 imgui-headers)
124 (for-each (lambda (f)
125 (install-file f (string-append
126 #$output
127 "/include/imgui/backends")))
128 backend-headers)
129 (for-each (lambda (f)
130 (install-file f (string-append #$output
131 "/include/imgui/"
132 (dirname f))))
133 misc-headers)
134 ;; Install examples.
135 (copy-recursively "examples"
136 (string-append #$output:doc
137 "/share/imgui/examples"))))))))
138 (inputs (list fontconfig freetype glfw mesa sdl2))
139 (home-page "https://github.com/ocornut/imgui")
140 (synopsis "Immediate-mode C++ GUI library with minimal dependencies")
141 (description "@code{dear imgui} (also know as ImGui) is a graphical user
142interface library for C++. It creates optimized vertex buffers that you can
143render anytime in your 3D-pipeline-enabled application. It's fast, portable,
144renderer-agnostic, and self-contained, without external dependencies.
145
146ImGui is aimed at content creation, visualization, and debugging tools as
147opposed to average end-user interfaces. Hence it favors simplicity and
148productivity but lacks certain features often found in higher-level libraries.
149It is particularly suited to integration in game engine tooling, real-time 3D
150applications, full-screen applications, and embedded platforms without
151standard operating system features.")
152 (license license:expat)))
153
154(define-public imgui-1.91
155 (package
156 (inherit imgui)
157 (name "imgui")
158 (version "1.91.9b")
159 (source (origin
160 (inherit (package-source imgui))
161 (method git-fetch)
162 (uri (git-reference
163 (url "https://github.com/ocornut/imgui")
164 (commit (string-append "v" version))))
165 (file-name (git-file-name name version))
166 (sha256
167 (base32
168 "1ji0fw0xb01c60hqzmvqi0ca5cnbm94x4v371f3w03q7zl6a8jvn"))))))
169
170(define-public imgui-for-mangohud
171 (package
172 (inherit imgui-1.91)
173 (arguments
174 (substitute-keyword-arguments arguments
175 ((#:make-flags flags ''())
176 ;; Remove "-DImDrawIdx=unsigned int" and "-DIMGUI_ENABLE_FREETYPE"
177 ;; from make-flags as this breaks MangoHud, the only user of this
178 ;; version.
179 #~(filter (negate (lambda (x) (string-prefix? "-D" x)))
180 #$flags))))
181 (inputs
182 (modify-inputs inputs
183 (delete "freetype")))))
184
185(define-public motif
186 ;; This commit is from February 2023 and v2.3.8 from 2017.
187 (let ((commit "0f556b0873c72ba1152a12fd54c3198ee039e413")
188 (revision "1"))
189 (package
190 (name "motif")
191 (version (git-version "2.3.8" revision commit))
192 (source
193 (origin
194 (method git-fetch)
195 (uri (git-reference
196 (url "https://git.code.sf.net/p/motif/code")
197 (commit commit)))
198 (file-name (git-file-name name version))
199 (sha256
200 (base32
201 "1g28i4978p9dpcdxv2yx4m17bchdypm3yy6m6gzchdlrv2iklhl9"))))
202 (build-system gnu-build-system)
203 (inputs
204 (list libx11 xorgproto))
205 (propagated-inputs
206 (list fontconfig freetype libxext libxft libxpm libxt xbitmaps))
207 (native-inputs
208 ;; This fails to build with GCC 14 due to missing header includes and
209 ;; other C semantics issues.
210 (list gcc-11
211 autoconf
212 automake
213 byacc
214 flex
215 libtool
216 pkg-config))
217 (home-page "https://motif.ics.com/motif")
218 (synopsis "Toolkit for the X window system")
219 (description
220 "Motif is a standard graphical user interface (as defined by the IEEE
2211295 specification), used on more than 200 hardware and software platforms.
222It provides application developers, end users, and system vendors with a
223widely used environment for standardizing application presentation on a wide
224range of platforms.")
225 (license license:lgpl2.1+))))
226
227(define-public nuklear
228 (package
229 (name "nuklear")
230 (version "4.12.0")
231 (home-page "https://github.com/Immediate-Mode-UI/Nuklear")
232 (source
233 (origin
234 (method git-fetch)
235 (uri (git-reference
236 (url home-page)
237 (commit version)))
238 (file-name (git-file-name name version))
239 (sha256
240 (base32 "13cswwdys4hqdvbm4g4b9l269i16s7c4204j16v67ghj3b4mjifg"))
241 (snippet #~(begin
242 (delete-file "nuklear.h")
243 (delete-file "doc/index.html")))))
244 (build-system pyproject-build-system)
245 (arguments
246 (list
247 #:tests? #f ;no tests
248 #:phases
249 #~(modify-phases %standard-phases
250 (delete 'configure)
251 (replace 'build
252 (lambda _
253 (with-directory-excursion "src"
254 (invoke "./paq.sh"))
255 (with-directory-excursion "doc"
256 (with-input-from-file "../nuklear.h"
257 (lambda _
258 (with-output-to-file "index.html"
259 (lambda _
260 (invoke "stddoc"))))))))
261 (replace 'install
262 (lambda _
263 (install-file "nuklear.h"
264 (string-append #$output "/include"))
265 (install-file "doc/index.html"
266 (string-append #$output "/share/doc")))))))
267 (native-inputs (list stddoc python-setuptools))
268 (synopsis "Graphical user interface toolkit written in ANSI C")
269 (description
270 "This package provides an immediate-mode graphical user interface
271toolkit. It was designed as an embeddable user interface for applications and
272does not have any dependencies, a default render backend or OS window/input
273handling. The library is self contained in one single header file and can be
274used either in header only mode or in implementation mode.")
275 (license (list license:unlicense license:expat))))
276
277(define-public implot
278 (package
279 (name "implot")
280 (version "0.16")
281 (source (origin
282 (method git-fetch)
283 (uri (git-reference
284 (url "https://github.com/epezent/implot")
285 (commit (string-append "v" version))))
286 (file-name (git-file-name name version))
287 (sha256
288 (base32
289 "0vbsw1qsi7j6pdz77840pxcqcghcl9fld80hchajbhpp1jr1a2gz"))))
290 (build-system gnu-build-system)
291 (arguments
292 (list
293 #:phases
294 #~(modify-phases %standard-phases
295 (delete 'bootstrap)
296 (delete 'configure)
297 (replace 'build
298 ;; Build a shared library from the source code.
299 (lambda* (#:key inputs #:allow-other-keys)
300 (invoke #$(cc-for-target) "-I" (getcwd)
301 "-I" (search-input-directory inputs "include/imgui")
302 "-g" "-O2" "-fPIC" "-shared"
303 "-o" "libimplot.so"
304 "implot.cpp"
305 "implot_items.cpp")))
306 (replace 'install
307 ;; Copy the library and header files to the output.
308 (lambda _
309 (install-file "libimplot.so" (string-append #$output "/lib"))
310 (for-each (lambda (file-name)
311 (install-file file-name
312 (string-append #$output
313 "/include/implot")))
314 '("implot.h" "implot_internal.h")))))
315 #:tests? #f)) ; no test suite
316 (inputs
317 (list imgui-1.91))
318 (home-page "https://github.com/epezent/implot")
319 (synopsis "Immediate-mode C++ plotting library for ImGui")
320 (description "ImPlot is an immediate-mode, GPU-accelerated plotting
321library in C++ for the ImGui GUI library, suitable for creating real-time
322visualizations or interactive plots. Like ImGui, ImPlot is self-contained and
323requires only minimal code to integrate with existing applications.")
324 (license license:expat)))