rakudo.scm 5.3 KB

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