projects/guix·blob java-team · refs

358 lines · 14.6 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, 2026 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.9b")
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 "0m35zy4j1m7pvlymxhmg8gcll58acil0il1x79iyyakksylvwd92"))
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" "-lSDL3" "-lfreetype" "-lglfw"
82 "-o" "libimgui.so")
83 #:phases
84 #~(modify-phases %standard-phases
85 (delete 'configure)
86 (replace 'build
87 (lambda* (#:key inputs make-flags #:allow-other-keys)
88 ;; Build main library.
89 (define sdl3?
90 (false-if-exception
91 (search-input-file inputs "lib/libSDL3.so")))
92 (unless sdl3?
93 (substitute* (find-files "." "(\\.cpp|\\.mm)$")
94 (("#include <SDL")
95 "#include <SDL2/SDL")))
96 (define args
97 (append make-flags
98 `("imgui.cpp"
99 "imgui_draw.cpp"
100 "imgui_tables.cpp"
101 "imgui_widgets.cpp"
102 ;; Include the supported backends.
103 "backends/imgui_impl_glfw.cpp"
104 ,(if sdl3?
105 "backends/imgui_impl_sdl3.cpp"
106 "backends/imgui_impl_sdl2.cpp")
107 "backends/imgui_impl_opengl2.cpp"
108 "backends/imgui_impl_opengl3.cpp"
109 ;; Include wrappers for C++ standard library
110 ;; (STL) and fontconfig.
111 ,@(find-files "misc" "\\.cpp$"))))
112 (format #t "invoking ~s with arguments: ~s~%"
113 #$(cc-for-target) args)
114 (apply invoke #$(cc-for-target) args)))
115 (replace 'install
116 (lambda _
117 (let* ((header? (cut string-suffix? ".h" <>))
118 (imgui-headers (scandir "." header?))
119 (backend-headers (find-files
120 "backends"
121 "(glfw|opengl|sdl|vulkan).*\\.h$"))
122 (misc-headers (find-files "misc" "\\.h$")))
123 (install-file "libimgui.so" (string-append #$output "/lib"))
124 ;; Install headers.
125 (for-each (lambda (f)
126 (install-file f (string-append #$output
127 "/include/imgui")))
128 imgui-headers)
129 (for-each (lambda (f)
130 (install-file f (string-append
131 #$output
132 "/include/imgui/backends")))
133 backend-headers)
134 (for-each (lambda (f)
135 (install-file f (string-append #$output
136 "/include/imgui/"
137 (dirname f))))
138 misc-headers)
139 ;; Install examples.
140 (copy-recursively "examples"
141 (string-append #$output:doc
142 "/share/imgui/examples"))))))))
143 (inputs (list fontconfig freetype glfw mesa sdl3))
144 (home-page "https://github.com/ocornut/imgui")
145 (synopsis "Immediate-mode C++ GUI library with minimal dependencies")
146 (description "@code{dear imgui} (also know as ImGui) is a graphical user
147interface library for C++. It creates optimized vertex buffers that you can
148render anytime in your 3D-pipeline-enabled application. It's fast, portable,
149renderer-agnostic, and self-contained, without external dependencies.
150
151ImGui is aimed at content creation, visualization, and debugging tools as
152opposed to average end-user interfaces. Hence it favors simplicity and
153productivity but lacks certain features often found in higher-level libraries.
154It is particularly suited to integration in game engine tooling, real-time 3D
155applications, full-screen applications, and embedded platforms without
156standard operating system features.")
157 (license license:expat)))
158
159(define-public imgui-with-sdl2
160 (package/inherit imgui
161 (name "imgui-with-sdl2")
162 (arguments (substitute-keyword-arguments arguments
163 ((#:make-flags flags ''())
164 #~(cons* "-lSDL2" (delete "-lSDL3" #$flags)))))
165 (inputs (modify-inputs inputs
166 (replace "sdl3" sdl2)))))
167
168(define-public imgui-1.91
169 (package
170 (inherit imgui)
171 (name "imgui")
172 (version "1.91.9b")
173 (source (origin
174 (inherit (package-source imgui))
175 (method git-fetch)
176 (uri (git-reference
177 (url "https://github.com/ocornut/imgui")
178 (commit (string-append "v" version))))
179 (file-name (git-file-name name version))
180 (sha256
181 (base32
182 "1ji0fw0xb01c60hqzmvqi0ca5cnbm94x4v371f3w03q7zl6a8jvn"))))))
183
184(define-public imgui-for-mangohud
185 (package
186 (inherit imgui-1.91)
187 (arguments
188 (substitute-keyword-arguments arguments
189 ((#:make-flags flags ''())
190 ;; Remove "-DImDrawIdx=unsigned int" and "-DIMGUI_ENABLE_FREETYPE"
191 ;; from make-flags as this breaks MangoHud, the only user of this
192 ;; version.
193 #~(filter (negate (lambda (x) (string-prefix? "-D" x)))
194 #$flags))))
195 (inputs
196 (modify-inputs inputs
197 (delete "freetype")))))
198
199(define-public motif
200 ;; This commit is from February 2023 and v2.3.8 from 2017.
201 (let ((commit "0f556b0873c72ba1152a12fd54c3198ee039e413")
202 (revision "1"))
203 (package
204 (name "motif")
205 (version (git-version "2.3.8" revision commit))
206 (source
207 (origin
208 (method git-fetch)
209 (uri (git-reference
210 (url "https://git.code.sf.net/p/motif/code")
211 (commit commit)))
212 (file-name (git-file-name name version))
213 (sha256
214 (base32
215 "1g28i4978p9dpcdxv2yx4m17bchdypm3yy6m6gzchdlrv2iklhl9"))))
216 (build-system gnu-build-system)
217 (inputs
218 (list libx11 xorgproto))
219 (propagated-inputs
220 (list fontconfig freetype libxext libxft libxpm libxt xbitmaps))
221 (native-inputs
222 ;; This fails to build with GCC 14 due to missing header includes and
223 ;; other C semantics issues.
224 (list gcc-11
225 autoconf
226 automake
227 byacc
228 flex
229 libtool
230 pkg-config))
231 (home-page "https://motif.ics.com/motif")
232 (synopsis "Toolkit for the X window system")
233 (description
234 "Motif is a standard graphical user interface (as defined by the IEEE
2351295 specification), used on more than 200 hardware and software platforms.
236It provides application developers, end users, and system vendors with a
237widely used environment for standardizing application presentation on a wide
238range of platforms.")
239 (license license:lgpl2.1+))))
240
241(define-public nuklear
242 (package
243 (name "nuklear")
244 (version "4.12.0")
245 (home-page "https://github.com/Immediate-Mode-UI/Nuklear")
246 (source
247 (origin
248 (method git-fetch)
249 (uri (git-reference
250 (url home-page)
251 (commit version)))
252 (file-name (git-file-name name version))
253 (sha256
254 (base32 "13cswwdys4hqdvbm4g4b9l269i16s7c4204j16v67ghj3b4mjifg"))
255 (snippet #~(begin
256 (delete-file "nuklear.h")
257 (delete-file "doc/index.html")))))
258 (build-system pyproject-build-system)
259 (arguments
260 (list
261 #:tests? #f ;no tests
262 #:phases
263 #~(modify-phases %standard-phases
264 (delete 'configure)
265 (replace 'build
266 (lambda _
267 (with-directory-excursion "src"
268 (invoke "./paq.sh"))
269 (with-directory-excursion "doc"
270 (with-input-from-file "../nuklear.h"
271 (lambda _
272 (with-output-to-file "index.html"
273 (lambda _
274 (invoke "stddoc"))))))))
275 (replace 'install
276 (lambda _
277 (install-file "nuklear.h"
278 (string-append #$output "/include"))
279 (install-file "doc/index.html"
280 (string-append #$output "/share/doc")))))))
281 (native-inputs (list stddoc python-setuptools))
282 (synopsis "Graphical user interface toolkit written in ANSI C")
283 (description
284 "This package provides an immediate-mode graphical user interface
285toolkit. It was designed as an embeddable user interface for applications and
286does not have any dependencies, a default render backend or OS window/input
287handling. The library is self contained in one single header file and can be
288used either in header only mode or in implementation mode.")
289 (license (list license:unlicense license:expat))))
290
291(define-public implot
292 (package
293 (name "implot")
294 (version "1.0")
295 (source (origin
296 (method git-fetch)
297 (uri (git-reference
298 (url "https://github.com/epezent/implot")
299 (commit (string-append "v" version))))
300 (file-name (git-file-name name version))
301 (sha256
302 (base32
303 "1pcq6nn82qpkwk27kyiaxky4pnaz9kj3fc3q25laj154r83ppikl"))))
304 (build-system gnu-build-system)
305 (arguments
306 (list
307 #:phases
308 #~(modify-phases %standard-phases
309 (delete 'bootstrap)
310 (delete 'configure)
311 (replace 'build
312 ;; Build a shared library from the source code.
313 (lambda* (#:key inputs #:allow-other-keys)
314 (invoke #$(cc-for-target) "-I" (getcwd)
315 "-I" (search-input-directory inputs "include/imgui")
316 "-g" "-O2" "-fPIC" "-shared"
317 "-o" "libimplot.so"
318 "implot.cpp"
319 "implot_items.cpp")))
320 (replace 'install
321 ;; Copy the library and header files to the output.
322 (lambda _
323 (install-file "libimplot.so" (string-append #$output "/lib"))
324 (for-each (lambda (file-name)
325 (install-file file-name
326 (string-append #$output
327 "/include/implot")))
328 '("implot.h" "implot_internal.h")))))
329 #:tests? #f)) ; no test suite
330 (inputs (list imgui))
331 (home-page "https://github.com/epezent/implot")
332 (synopsis "Immediate-mode C++ plotting library for ImGui")
333 (description "ImPlot is an immediate-mode, GPU-accelerated plotting
334library in C++ for the ImGui GUI library, suitable for creating real-time
335visualizations or interactive plots. Like ImGui, ImPlot is self-contained and
336requires only minimal code to integrate with existing applications.")
337 (license license:expat)))
338
339(define-public implot-0
340 (package
341 (inherit implot)
342 (name "implot")
343 (version "0.17")
344 (source (origin
345 (method git-fetch)
346 (uri (git-reference
347 (url "https://github.com/epezent/implot")
348 (commit (string-append "v" version))))
349 (file-name (git-file-name name version))
350 (sha256
351 (base32
352 "1rp4lxgr11yc3z3cmlrpyaf916n74wp7401r21v7xbybfd2cvp0w"))))))
353
354(define-public implot-for-mangohud
355 (package
356 (inherit implot-0)
357 (inputs (modify-inputs inputs
358 (replace "imgui" imgui-for-mangohud)))))