1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
3 ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu packages stb)
21 #:use-module (guix packages)
22 #:use-module (guix git-download)
23 #:use-module (guix build-system gnu)
24 #:use-module (guix build-system trivial)
25 #:use-module ((guix licenses) #:select (expat public-domain)))
28 ;; stb is a collection of libraries developed within the same repository.
29 ;; When updating this, remember to change versions below as appropriate.
30 (let ((commit "b42009b3b9d4ca35bc703f5310eedc74f584be58")
34 (home-page "https://github.com/nothings/stb")
35 (version (git-version "0.0" revision commit))
43 "1gmcjhmj62mfdscrsg2hv4j4j9v447y8zj3rbrm7mqn94cx73z1i"))
44 (file-name (git-file-name name version))))
45 (build-system gnu-build-system)
47 `(#:modules ((ice-9 ftw)
50 ,@%gnu-build-system-modules)
51 #:phases (modify-phases %standard-phases
56 (invoke "make" "-C" "tests" "CC=gcc")))
58 (lambda* (#:key outputs #:allow-other-keys)
59 (let ((out (assoc-ref outputs "out"))
60 (files (make-regexp "\\.(c|h|md)$")))
61 (for-each (lambda (file)
62 (install-file file out))
63 (scandir "." (cut regexp-exec files <>)))
65 (synopsis "Single file libraries for C/C++")
67 "This package contains a variety of small independent libraries for
68 the C programming language.")
69 ;; The user can choose either license.
70 (license (list expat public-domain)))))
72 (define (make-stb-header-package name version description)
78 (inputs `(("stb" ,stb)))
79 (build-system trivial-build-system)
81 `(#:modules ((guix build utils))
83 (use-modules (guix build utils))
84 (let ((stb (assoc-ref %build-inputs "stb"))
85 (lib (string-join (string-split ,name #\-) "_"))
86 (out (assoc-ref %outputs "out")))
87 (install-file (string-append stb "/" lib ".h")
88 (string-append out "/include"))
90 (description description)))
92 ;; TODO: These descriptions are not translatable! They should be
93 ;; converted to macros as outlined in <https://bugs.gnu.org/32155>.
94 (define-public stb-image
95 (make-stb-header-package
97 "stb-image is a small and self-contained library for image loading or
98 decoding from file or memory. A variety of formats are supported."))
100 (define-public stb-image-write
101 (make-stb-header-package
102 "stb-image-write" "1.15"
103 "stb-image-write is a small library for writing image files to the
104 C@tie{}@code{stdio} interface."))
106 (define-public stb-rect-pack
107 (make-stb-header-package
108 "stb-rect-pack" "1.00"
109 "stb-rect-pack is a small rectangle packing library useful for, e.g., packing
110 rectangular textures into an atlas. It does not do rotation."))
112 (define-public stb-sprintf
113 (make-stb-header-package
115 "stb-sprintf implements fast @code{sprintf}, @code{snprintf} for C/C++."))
117 (define-public stb-truetype
118 (make-stb-header-package
119 "stb-truetype" "1.24"
120 "stb-truetype is a library for parsing, decoding, and rasterizing
121 characters from TrueType fonts."))