stb.scm 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. (define-module (gnu packages stb)
  19. #:use-module (guix packages)
  20. #:use-module (guix git-download)
  21. #:use-module (guix build-system gnu)
  22. #:use-module (guix build-system trivial)
  23. #:use-module ((guix licenses) #:select (expat public-domain)))
  24. (define stb
  25. ;; stb is a collection of libraries developed within the same repository.
  26. ;; When updating this, remember to change versions below as appropriate.
  27. (let ((commit "e6afb9cbae4064da8c3e69af3ff5c4629579c1d2")
  28. (revision "0"))
  29. (package
  30. (name "stb")
  31. (home-page "https://github.com/nothings/stb")
  32. (version (git-version "0.0" revision commit))
  33. (source (origin
  34. (method git-fetch)
  35. (uri (git-reference
  36. (url home-page)
  37. (commit commit)))
  38. (sha256
  39. (base32
  40. "079nsn9bnb8c0vfq26g5l53q6gzx19a5x9q2nb55mpcljxsgxnmf"))
  41. (file-name (git-file-name name version))))
  42. (build-system gnu-build-system)
  43. (arguments
  44. `(#:modules ((ice-9 ftw)
  45. (ice-9 regex)
  46. (srfi srfi-26)
  47. ,@%gnu-build-system-modules)
  48. #:phases (modify-phases %standard-phases
  49. (delete 'configure)
  50. (delete 'build)
  51. (replace 'check
  52. (lambda _
  53. (invoke "make" "-C" "tests" "CC=gcc")))
  54. (replace 'install
  55. (lambda* (#:key outputs #:allow-other-keys)
  56. (let ((out (assoc-ref outputs "out"))
  57. (files (make-regexp "\\.(c|h|md)$")))
  58. (for-each (lambda (file)
  59. (install-file file out))
  60. (scandir "." (cut regexp-exec files <>)))
  61. #t))))))
  62. (synopsis "Single file libraries for C/C++")
  63. (description
  64. "This package contains a variety of small independent libraries for
  65. the C programming language.")
  66. ;; The user can choose either license.
  67. (license (list expat public-domain)))))
  68. (define (make-stb-header-package name version description)
  69. (package
  70. (inherit stb)
  71. (name name)
  72. (version version)
  73. (source #f)
  74. (inputs `(("stb" ,stb)))
  75. (build-system trivial-build-system)
  76. (arguments
  77. `(#:modules ((guix build utils))
  78. #:builder (begin
  79. (use-modules (guix build utils))
  80. (let ((stb (assoc-ref %build-inputs "stb"))
  81. (lib (string-join (string-split ,name #\-) "_"))
  82. (out (assoc-ref %outputs "out")))
  83. (install-file (string-append stb "/" lib ".h")
  84. (string-append out "/include"))
  85. #t))))
  86. (description description)))
  87. ;; TODO: These descriptions are not translatable! They should be
  88. ;; converted to macros as outlined in <https://bugs.gnu.org/32155>.
  89. (define-public stb-image
  90. (make-stb-header-package
  91. "stb-image" "2.19"
  92. "stb-image is a small and self-contained library for image loading or
  93. decoding from file or memory. A variety of formats are supported."))
  94. (define-public stb-image-write
  95. (make-stb-header-package
  96. "stb-image-write" "1.09"
  97. "stb-image-write is a small library for writing image files to the
  98. C@tie{}@code{stdio} interface."))