rakudo.scm 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
  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 rakudo)
  20. #:use-module (guix store)
  21. #:use-module (guix utils)
  22. #:use-module (guix gexp)
  23. #:use-module (guix monads)
  24. #:use-module (guix search-paths)
  25. #:use-module (guix build-system)
  26. #:use-module (guix build-system gnu)
  27. #:use-module (guix packages)
  28. #:export (%rakudo-build-system-modules
  29. rakudo-build
  30. rakudo-build-system))
  31. ;; Commentary:
  32. ;;
  33. ;; Standard build and install procedure for packages using the Rakudo
  34. ;; build system to be installed as system libraries. This is
  35. ;; implemented as an extension of `gnu-build-system'.
  36. ;;
  37. ;; Code:
  38. (define %rakudo-build-system-modules
  39. ;; Build-side modules imported by default.
  40. `((guix build rakudo-build-system)
  41. ,@%gnu-build-system-modules))
  42. (define (default-rakudo)
  43. "Return the default Rakudo package."
  44. ;; Do not use `@' to avoid introducing circular dependencies.
  45. (let ((module (resolve-interface '(gnu packages perl6))))
  46. (module-ref module 'rakudo)))
  47. (define (default-prove6)
  48. "Return the default perl6-tap-harness package for tests."
  49. (let ((module (resolve-interface '(gnu packages perl6))))
  50. (module-ref module 'perl6-tap-harness)))
  51. (define (default-zef)
  52. "Return the default perl6-zef package."
  53. (let ((module (resolve-interface '(gnu packages perl6))))
  54. (module-ref module 'perl6-zef)))
  55. (define* (lower name
  56. #:key source inputs native-inputs outputs
  57. system target
  58. (rakudo (default-rakudo))
  59. (prove6 (default-prove6))
  60. (zef (default-zef))
  61. (with-prove6? #t)
  62. (with-zef? #t)
  63. #:allow-other-keys
  64. #:rest arguments)
  65. "Return a bag for NAME."
  66. (define private-keywords
  67. '(#:target #:rakudo #:prove6 #:zef #:inputs #:native-inputs))
  68. (and (not target) ;XXX: no cross-compilation
  69. (bag
  70. (name name)
  71. (system system)
  72. (host-inputs `(,@(if source
  73. `(("source" ,source))
  74. '())
  75. ,@inputs
  76. ;; Keep the standard inputs of 'gnu-build-system'.
  77. ,@(standard-packages)))
  78. (build-inputs `(("rakudo" ,rakudo)
  79. ,@(if with-prove6?
  80. `(("perl6-tap-harness" ,prove6)
  81. ,@(if with-zef?
  82. `(("perl6-zef" ,zef))
  83. '()))
  84. '())
  85. ,@native-inputs))
  86. (outputs outputs)
  87. (build rakudo-build)
  88. (arguments (strip-keyword-arguments private-keywords arguments)))))
  89. (define* (rakudo-build name inputs
  90. #:key
  91. source
  92. (search-paths '())
  93. (tests? #t)
  94. (phases '%standard-phases)
  95. (outputs '("out"))
  96. (system (%current-system))
  97. (guile #f)
  98. (with-zef? #t)
  99. (with-prove6? #t)
  100. (imported-modules %rakudo-build-system-modules)
  101. (modules '((guix build rakudo-build-system)
  102. (guix build utils))))
  103. "Build SOURCE using PERL6, and with INPUTS."
  104. (define builder
  105. (with-imported-modules imported-modules
  106. #~(begin
  107. (use-modules #$@(sexp->gexp modules))
  108. (rakudo-build #:name #$name
  109. #:source #+source
  110. #:search-paths '#$(sexp->gexp
  111. (map search-path-specification->sexp
  112. search-paths))
  113. #:phases #$phases
  114. #:system #$system
  115. #:tests? #$tests?
  116. #:outputs #$(outputs->gexp outputs)
  117. #:inputs #$(input-tuples->gexp inputs)))))
  118. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  119. system #:graft? #f)))
  120. (gexp->derivation name builder
  121. #:system system
  122. #:guile-for-build guile)))
  123. (define rakudo-build-system
  124. (build-system
  125. (name 'rakudo)
  126. (description "The standard Rakudo build system")
  127. (lower lower)))
  128. ;;; rakudo.scm ends here