stb.scm 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. (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. (define stb
  26. ;; stb is a collection of libraries developed within the same repository.
  27. ;; When updating this, remember to change versions below as appropriate.
  28. (let ((commit "b42009b3b9d4ca35bc703f5310eedc74f584be58")
  29. (revision "2"))
  30. (package
  31. (name "stb")
  32. (home-page "https://github.com/nothings/stb")
  33. (version (git-version "0.0" revision commit))
  34. (source (origin
  35. (method git-fetch)
  36. (uri (git-reference
  37. (url home-page)
  38. (commit commit)))
  39. (sha256
  40. (base32
  41. "1gmcjhmj62mfdscrsg2hv4j4j9v447y8zj3rbrm7mqn94cx73z1i"))
  42. (file-name (git-file-name name version))))
  43. (build-system gnu-build-system)
  44. (arguments
  45. `(#:modules ((ice-9 ftw)
  46. (ice-9 regex)
  47. (srfi srfi-26)
  48. ,@%gnu-build-system-modules)
  49. #:phases (modify-phases %standard-phases
  50. (delete 'configure)
  51. (delete 'build)
  52. (replace 'check
  53. (lambda _
  54. (invoke "make" "-C" "tests" "CC=gcc")))
  55. (replace 'install
  56. (lambda* (#:key outputs #:allow-other-keys)
  57. (let ((out (assoc-ref outputs "out"))
  58. (files (make-regexp "\\.(c|h|md)$")))
  59. (for-each (lambda (file)
  60. (install-file file out))
  61. (scandir "." (cut regexp-exec files <>)))
  62. #t))))))
  63. (synopsis "Single file libraries for C/C++")
  64. (description
  65. "This package contains a variety of small independent libraries for
  66. the C programming language.")
  67. ;; The user can choose either license.
  68. (license (list expat public-domain)))))
  69. (define (make-stb-header-package name version description)
  70. (package
  71. (inherit stb)
  72. (name name)
  73. (version version)
  74. (source #f)
  75. (inputs `(("stb" ,stb)))
  76. (build-system trivial-build-system)
  77. (arguments
  78. `(#:modules ((guix build utils))
  79. #:builder (begin
  80. (use-modules (guix build utils))
  81. (let ((stb (assoc-ref %build-inputs "stb"))
  82. (lib (string-join (string-split ,name #\-) "_"))
  83. (out (assoc-ref %outputs "out")))
  84. (install-file (string-append stb "/" lib ".h")
  85. (string-append out "/include"))
  86. #t))))
  87. (description description)))
  88. ;; TODO: These descriptions are not translatable! They should be
  89. ;; converted to macros as outlined in <https://bugs.gnu.org/32155>.
  90. (define-public stb-image
  91. (make-stb-header-package
  92. "stb-image" "2.26"
  93. "stb-image is a small and self-contained library for image loading or
  94. decoding from file or memory. A variety of formats are supported."))
  95. (define-public stb-image-write
  96. (make-stb-header-package
  97. "stb-image-write" "1.15"
  98. "stb-image-write is a small library for writing image files to the
  99. C@tie{}@code{stdio} interface."))
  100. (define-public stb-rect-pack
  101. (make-stb-header-package
  102. "stb-rect-pack" "1.00"
  103. "stb-rect-pack is a small rectangle packing library useful for, e.g., packing
  104. rectangular textures into an atlas. It does not do rotation."))
  105. (define-public stb-sprintf
  106. (make-stb-header-package
  107. "stb-sprintf" "1.09"
  108. "stb-sprintf implements fast @code{sprintf}, @code{snprintf} for C/C++."))
  109. (define-public stb-truetype
  110. (make-stb-header-package
  111. "stb-truetype" "1.24"
  112. "stb-truetype is a library for parsing, decoding, and rasterizing
  113. characters from TrueType fonts."))