renpy.scm 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2021 Leo Prikler <leo.prikler@student.tugraz.at>
  3. ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
  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 (guix build-system renpy)
  20. #:use-module (guix store)
  21. #:use-module (guix utils)
  22. #:use-module (guix memoization)
  23. #:use-module (guix packages)
  24. #:use-module (guix gexp)
  25. #:use-module (guix monads)
  26. #:use-module (guix search-paths)
  27. #:use-module (guix build-system)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (ice-9 match)
  30. #:use-module (srfi srfi-1)
  31. #:use-module (srfi srfi-26)
  32. #:export (%renpy-build-system-modules
  33. default-renpy
  34. renpy-build
  35. renpy-build-system))
  36. (define (default-renpy)
  37. "Return the default Ren'py package."
  38. ;; Lazily resolve the binding to avoid a circular dependency.
  39. (let ((module (resolve-interface '(gnu packages game-development))))
  40. (module-ref module 'renpy)))
  41. (define %renpy-build-system-modules
  42. ;; Build-side modules imported by default.
  43. `((guix build renpy-build-system)
  44. (guix build json)
  45. (guix build python-build-system)
  46. ,@%gnu-build-system-modules))
  47. (define* (lower name
  48. #:key source inputs native-inputs outputs system target
  49. (renpy (default-renpy))
  50. #:allow-other-keys
  51. #:rest arguments)
  52. "Return a bag for NAME."
  53. (define private-keywords
  54. '(#:target #:renpy #:inputs #:native-inputs))
  55. (and (not target) ;XXX: no cross-compilation
  56. (bag
  57. (name name)
  58. (system system)
  59. (host-inputs `(,@(if source
  60. `(("source" ,source))
  61. '())
  62. ,@inputs
  63. ;; Keep the standard inputs of 'gnu-build-system'.
  64. ,@(standard-packages)))
  65. (build-inputs `(("renpy" ,renpy)
  66. ,@native-inputs))
  67. (outputs outputs)
  68. (build renpy-build)
  69. (arguments (strip-keyword-arguments private-keywords arguments)))))
  70. (define* (renpy-build name inputs
  71. #:key
  72. source
  73. (phases '%standard-phases)
  74. (configure-flags ''())
  75. (outputs '("out"))
  76. (output "out")
  77. (game "game")
  78. (search-paths '())
  79. (system (%current-system))
  80. (guile #f)
  81. (imported-modules %renpy-build-system-modules)
  82. (modules '((guix build renpy-build-system)
  83. (guix build utils))))
  84. "Build SOURCE using RENPY, and with INPUTS."
  85. (define builder
  86. (with-imported-modules imported-modules
  87. #~(begin
  88. (use-modules #$@(sexp->gexp modules))
  89. (renpy-build #:name #$name
  90. #:source #+source
  91. #:configure-flags #$configure-flags
  92. #:system #$system
  93. #:phases #$phases
  94. #:outputs #$(outputs->gexp outputs)
  95. #:output #$output
  96. #:game #$game
  97. #:search-paths '#$(sexp->gexp
  98. (map search-path-specification->sexp
  99. search-paths))
  100. #:inputs #$(input-tuples->gexp inputs)))))
  101. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  102. system #:graft? #f)))
  103. (gexp->derivation name builder
  104. #:system system
  105. #:guile-for-build guile)))
  106. (define renpy-build-system
  107. (build-system
  108. (name 'renpy)
  109. (description "The Ren'py build system")
  110. (lower lower)))