| 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> |
| 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. |
| 6 | ;;; |
| 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. |
| 11 | ;;; |
| 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. |
| 16 | ;;; |
| 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/>. |
| 19 | |
| 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))) |
| 26 | |
| 27 | (define stb |
| 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") |
| 31 | (revision "2")) |
| 32 | (package |
| 33 | (name "stb") |
| 34 | (home-page "https://github.com/nothings/stb") |
| 35 | (version (git-version "0.0" revision commit)) |
| 36 | (source (origin |
| 37 | (method git-fetch) |
| 38 | (uri (git-reference |
| 39 | (url home-page) |
| 40 | (commit commit))) |
| 41 | (sha256 |
| 42 | (base32 |
| 43 | "1gmcjhmj62mfdscrsg2hv4j4j9v447y8zj3rbrm7mqn94cx73z1i")) |
| 44 | (file-name (git-file-name name version)))) |
| 45 | (build-system gnu-build-system) |
| 46 | (arguments |
| 47 | `(#:modules ((ice-9 ftw) |
| 48 | (ice-9 regex) |
| 49 | (srfi srfi-26) |
| 50 | ,@%gnu-build-system-modules) |
| 51 | #:phases (modify-phases %standard-phases |
| 52 | (delete 'configure) |
| 53 | (delete 'build) |
| 54 | (replace 'check |
| 55 | (lambda _ |
| 56 | (invoke "make" "-C" "tests" "CC=gcc"))) |
| 57 | (replace 'install |
| 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 <>))) |
| 64 | #t)))))) |
| 65 | (synopsis "Single file libraries for C/C++") |
| 66 | (description |
| 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))))) |
| 71 | |
| 72 | (define (make-stb-header-package name version description) |
| 73 | (package |
| 74 | (inherit stb) |
| 75 | (name name) |
| 76 | (version version) |
| 77 | (source #f) |
| 78 | (inputs `(("stb" ,stb))) |
| 79 | (build-system trivial-build-system) |
| 80 | (arguments |
| 81 | `(#:modules ((guix build utils)) |
| 82 | #:builder (begin |
| 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")) |
| 89 | #t)))) |
| 90 | (description description))) |
| 91 | |
| 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 |
| 96 | "stb-image" "2.26" |
| 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.")) |
| 99 | |
| 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.")) |
| 105 | |
| 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.")) |
| 111 | |
| 112 | (define-public stb-sprintf |
| 113 | (make-stb-header-package |
| 114 | "stb-sprintf" "1.09" |
| 115 | "stb-sprintf implements fast @code{sprintf}, @code{snprintf} for C/C++.")) |
| 116 | |
| 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.")) |