renpy.scm 4.5 KB

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