renpy.scm 4.5 KB

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