Commit | Line | Data |
---|---|---|
cada868c MB |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
7 | ;;; under the terms of the GNU General Public License as published by | |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | ;;; your option) any later version. | |
10 | ;;; | |
11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;;; GNU General Public License for more details. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | (define-module (gnu packages stb) | |
20 | #:use-module (guix packages) | |
21 | #:use-module (guix git-download) | |
22 | #:use-module (guix build-system gnu) | |
23 | #:use-module (guix build-system trivial) | |
24 | #:use-module ((guix licenses) #:select (expat public-domain))) | |
25 | ||
26 | (define stb | |
27 | ;; stb is a collection of libraries developed within the same repository. | |
28 | ;; When updating this, remember to change versions below as appropriate. | |
d3b22d48 MB |
29 | (let ((commit "2c2908f50515dcd939f24be261c3ccbcd277bb49") |
30 | (revision "1")) | |
cada868c MB |
31 | (package |
32 | (name "stb") | |
33 | (home-page "https://github.com/nothings/stb") | |
34 | (version (git-version "0.0" revision commit)) | |
35 | (source (origin | |
36 | (method git-fetch) | |
37 | (uri (git-reference | |
38 | (url home-page) | |
39 | (commit commit))) | |
40 | (sha256 | |
41 | (base32 | |
d3b22d48 | 42 | "1z753rscqc4clp0rd57bw68i60kz694y1z52bwv6slzmkgds1cki")) |
cada868c MB |
43 | (file-name (git-file-name name version)))) |
44 | (build-system gnu-build-system) | |
45 | (arguments | |
46 | `(#:modules ((ice-9 ftw) | |
47 | (ice-9 regex) | |
48 | (srfi srfi-26) | |
49 | ,@%gnu-build-system-modules) | |
50 | #:phases (modify-phases %standard-phases | |
51 | (delete 'configure) | |
52 | (delete 'build) | |
53 | (replace 'check | |
54 | (lambda _ | |
55 | (invoke "make" "-C" "tests" "CC=gcc"))) | |
56 | (replace 'install | |
57 | (lambda* (#:key outputs #:allow-other-keys) | |
58 | (let ((out (assoc-ref outputs "out")) | |
59 | (files (make-regexp "\\.(c|h|md)$"))) | |
60 | (for-each (lambda (file) | |
61 | (install-file file out)) | |
62 | (scandir "." (cut regexp-exec files <>))) | |
63 | #t)))))) | |
64 | (synopsis "Single file libraries for C/C++") | |
65 | (description | |
66 | "This package contains a variety of small independent libraries for | |
67 | the C programming language.") | |
68 | ;; The user can choose either license. | |
69 | (license (list expat public-domain))))) | |
70 | ||
71 | (define (make-stb-header-package name version description) | |
72 | (package | |
73 | (inherit stb) | |
74 | (name name) | |
75 | (version version) | |
76 | (source #f) | |
77 | (inputs `(("stb" ,stb))) | |
78 | (build-system trivial-build-system) | |
79 | (arguments | |
80 | `(#:modules ((guix build utils)) | |
81 | #:builder (begin | |
82 | (use-modules (guix build utils)) | |
83 | (let ((stb (assoc-ref %build-inputs "stb")) | |
84 | (lib (string-join (string-split ,name #\-) "_")) | |
85 | (out (assoc-ref %outputs "out"))) | |
86 | (install-file (string-append stb "/" lib ".h") | |
87 | (string-append out "/include")) | |
88 | #t)))) | |
89 | (description description))) | |
90 | ||
91 | ;; TODO: These descriptions are not translatable! They should be | |
92 | ;; converted to macros as outlined in <https://bugs.gnu.org/32155>. | |
93 | (define-public stb-image | |
94 | (make-stb-header-package | |
d3b22d48 | 95 | "stb-image" "2.22" |
cada868c MB |
96 | "stb-image is a small and self-contained library for image loading or |
97 | decoding from file or memory. A variety of formats are supported.")) | |
ecb1194b MB |
98 | |
99 | (define-public stb-image-write | |
100 | (make-stb-header-package | |
d3b22d48 | 101 | "stb-image-write" "1.13" |
ecb1194b MB |
102 | "stb-image-write is a small library for writing image files to the |
103 | C@tie{}@code{stdio} interface.")) | |
8a4c7be4 GL |
104 | |
105 | (define-public stb-sprintf | |
106 | (make-stb-header-package | |
107 | "stb-sprintf" "1.06" | |
108 | "stb-sprintf implements fast @code{sprintf}, @code{snprintf} for C/C++.")) | |
6e43e1ee GL |
109 | |
110 | (define-public stb-truetype | |
111 | (make-stb-header-package | |
112 | "stb-truetype" "1.22" | |
113 | "stb-truetype is a library for parsing, decoding, and rasterizing | |
114 | characters from TrueType fonts.")) |