From 2d037af446b71d17f75aaeb8631c4eb346586150 Mon Sep 17 00:00:00 2001 From: Luis Guilherme Coelho Date: Tue, 12 Nov 2024 23:57:38 -0300 Subject: [PATCH] packages: stb: Add stb-image-resize2 --- radix/packages/stb.scm | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 radix/packages/stb.scm diff --git a/radix/packages/stb.scm b/radix/packages/stb.scm new file mode 100644 index 0000000..16c51a9 --- /dev/null +++ b/radix/packages/stb.scm @@ -0,0 +1,75 @@ +(define-module (radix packages stb) + #:use-module (guix packages) + #:use-module (guix git-download) + #:use-module (guix build-system gnu) + #:use-module (guix build-system trivial) + #:use-module ((guix licenses) #:select (expat public-domain))) + +(define stb + ;; stb is a collection of libraries developed within the same repository. + ;; When updating this, remember to change versions below as appropriate. + (let ((commit "5c205738c191bcb0abc65c4febfa9bd25ff35234") + (revision "0")) + (package + (name "stb") + (home-page "https://github.com/nothings/stb") + (version (git-version "0.0" revision commit)) + (source (origin + (method git-fetch) + (uri (git-reference + (url home-page) + (commit commit))) + (sha256 + (base32 + "1g8arc3rndy78fwyznwywxqcy2pwnf4w0220vj2197wrl6hn9r95")) + (file-name (git-file-name name version)))) + (build-system gnu-build-system) + (arguments + `(#:modules ((ice-9 ftw) + (ice-9 regex) + (srfi srfi-26) + ,@%default-gnu-modules) + #:phases (modify-phases %standard-phases + (delete 'configure) + (delete 'build) + (delete 'check) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out")) + (files (make-regexp "\\.(c|h|md)$"))) + (for-each (lambda (file) + (install-file file out)) + (scandir "." (cut regexp-exec files <>))) + #t)))))) + (synopsis "Single file libraries for C/C++") + (description + "This package contains a variety of small independent libraries for +the C programming language.") + ;; The user can choose either license. + (license (list expat public-domain))))) + +(define (make-stb-header-package name version description) + (package + (inherit stb) + (name name) + (version version) + (source #f) + (inputs (list stb)) + (build-system trivial-build-system) + (arguments + `(#:modules ((guix build utils)) + #:builder (begin + (use-modules (guix build utils)) + (let ((stb (assoc-ref %build-inputs "stb")) + (lib (string-join (string-split ,name #\-) "_")) + (out (assoc-ref %outputs "out"))) + (install-file (string-append stb "/" lib ".h") + (string-append out "/include")) + #t)))) + (description description))) + +(define-public stb-image-resize2 + (make-stb-header-package + "stb-image-resize2" "2.12" + "stb-image-resize is a library that supports scaling and translation of +images."))