projects/guix·blob javascript-team · refs

166 lines · 6.2 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018 Marius Bakke <[email protected]>
3;;; Copyright © 2020 Tobias Geerinckx-Rice <[email protected]>
4;;; Copyright © 2025 aurtzy <[email protected]>
5;;;
6;;; This file is part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (gnu packages stb)
22 #:use-module (guix gexp)
23 #:use-module (guix packages)
24 #:use-module (guix git-download)
25 #:use-module (guix build-system gnu)
26 #:use-module (guix build-system trivial)
27 #:use-module ((guix licenses) #:select (expat public-domain)))
28
29(define-public stb
30 ;; stb is a collection of libraries developed within the same repository.
31 ;; When updating this, remember to change versions below as appropriate.
32 (let ((commit "2e2bef463a5b53ddf8bb788e25da6b8506314c08")
33 (revision "3"))
34 (package
35 (name "stb")
36 (home-page "https://github.com/nothings/stb")
37 (version (git-version "0.0" revision commit))
38 (source (origin
39 (method git-fetch)
40 (uri (git-reference
41 (url home-page)
42 (commit commit)))
43 (sha256
44 (base32
45 "1n3klhrf65ndlzg88z0ligk9z4jdg4p296wnqivd1259834cj8gf"))
46 (file-name (git-file-name name version))))
47 (build-system gnu-build-system)
48 (arguments
49 (list
50 #:modules `((ice-9 ftw)
51 (ice-9 regex)
52 (srfi srfi-26)
53 ,@%default-gnu-modules)
54 #:phases
55 #~(modify-phases %standard-phases
56 (delete 'configure)
57 (delete 'build)
58 (replace 'check
59 (lambda _
60 #f ; (invoke "make" "-C" "tests" "CC=gcc")
61 ))
62 (replace 'install
63 (lambda _
64 (let* ((files-rx (make-regexp "\\.(c|h|md)$"))
65 (include-file? (cut regexp-exec files-rx <>))
66 (deprecated-output (string-append #$output "/deprecated"))
67 (pkgconfig (string-append #$output "/lib/pkgconfig"))
68 (pc (string-append pkgconfig "/stb.pc")))
69 (for-each (cut install-file <> #$output)
70 (scandir "." include-file?))
71 (mkdir-p deprecated-output)
72 (with-directory-excursion "deprecated"
73 (for-each (cut install-file <> deprecated-output)
74 (scandir "." include-file?)))
75 ;; Create stb.pc.
76 (mkdir-p pkgconfig)
77 (call-with-output-file pc
78 (lambda (port)
79 (format port
80 "prefix=~a
81includedir=${prefix}
82
83Name: stb
84Version: ~a
85Description: ~a
86Cflags: -I${includedir}~%"
87 #$output #$version
88 #$(package-synopsis this-package))))))))))
89 (synopsis "Single file libraries for C/C++")
90 (description
91 "This package contains a variety of small independent libraries for
92the C programming language.")
93 ;; The user can choose either license.
94 (license (list expat public-domain)))))
95
96(define* (make-stb-header-package name version description #:key deprecated?)
97 (package
98 (inherit stb)
99 (name name)
100 (version version)
101 (source #f)
102 (inputs (list stb))
103 (build-system trivial-build-system)
104 (arguments
105 (list
106 #:modules '((guix build utils))
107 #:builder
108 #~(begin
109 (use-modules (guix build utils))
110 (let ((headers-dir #$(file-append (this-package-input "stb")
111 (if deprecated? "/deprecated" "")))
112 (lib (string-join (string-split #$name #\-) "_"))
113 (out #$output))
114 (install-file (string-append headers-dir "/" lib ".h")
115 (string-append out "/include"))
116 #t))))
117 (description description)))
118
119(define-syntax define-stb-header-package
120 (syntax-rules (description)
121 ((_ symbol name version (description text) rest ...)
122 (define-public symbol
123 (make-stb-header-package name version text rest ...)))))
124
125(define-stb-header-package stb-image
126 "stb-image" "2.30"
127 (description
128 "stb-image is a small and self-contained library for image loading or
129decoding from file or memory. A variety of formats are supported."))
130
131(define-stb-header-package stb-image-resize
132 "stb-image-resize" "0.97"
133 (description
134 "stb-image-resize is a library that supports scaling and translation of
135images. This library is deprecated; @code{stb-image-resize2} should be used
136instead.")
137 #:deprecated? #t)
138
139(define-stb-header-package stb-image-resize2
140 "stb-image-resize2" "2.12"
141 (description
142 "stb-image-resize2 is a library that supports scaling and translation of
143images."))
144
145(define-stb-header-package stb-image-write
146 "stb-image-write" "1.16"
147 (description
148 "stb-image-write is a small library for writing image files to the
149C@tie{}@code{stdio} interface."))
150
151(define-stb-header-package stb-rect-pack
152 "stb-rect-pack" "1.01"
153 (description
154 "stb-rect-pack is a small rectangle packing library useful for, e.g., packing
155rectangular textures into an atlas. It does not do rotation."))
156
157(define-stb-header-package stb-sprintf
158 "stb-sprintf" "1.10"
159 (description
160 "stb-sprintf implements fast @code{sprintf}, @code{snprintf} for C/C++."))
161
162(define-stb-header-package stb-truetype
163 "stb-truetype" "1.26"
164 (description
165 "stb-truetype is a library for parsing, decoding, and rasterizing
166characters from TrueType fonts."))