rakudo.scm 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (guix build-system rakudo)
  19. #:use-module (guix store)
  20. #:use-module (guix utils)
  21. #:use-module (guix derivations)
  22. #:use-module (guix search-paths)
  23. #:use-module (guix build-system)
  24. #:use-module (guix build-system gnu)
  25. #:use-module (guix packages)
  26. #:use-module (ice-9 match)
  27. #:export (%rakudo-build-system-modules
  28. rakudo-build
  29. rakudo-build-system))
  30. ;; Commentary:
  31. ;;
  32. ;; Standard build and install procedure for packages using the Rakudo
  33. ;; build system to be installed as system libraries. This is
  34. ;; implemented as an extension of `gnu-build-system'.
  35. ;;
  36. ;; Code:
  37. (define %rakudo-build-system-modules
  38. ;; Build-side modules imported by default.
  39. `((guix build rakudo-build-system)
  40. ,@%gnu-build-system-modules))
  41. (define (default-rakudo)
  42. "Return the default Rakudo package."
  43. ;; Do not use `@' to avoid introducing circular dependencies.
  44. (let ((module (resolve-interface '(gnu packages perl6))))
  45. (module-ref module 'rakudo)))
  46. (define (default-prove6)
  47. "Return the default perl6-tap-harness package for tests."
  48. (let ((module (resolve-interface '(gnu packages perl6))))
  49. (module-ref module 'perl6-tap-harness)))
  50. (define (default-zef)
  51. "Return the default perl6-zef package."
  52. (let ((module (resolve-interface '(gnu packages perl6))))
  53. (module-ref module 'perl6-zef)))
  54. (define* (lower name
  55. #:key source inputs native-inputs outputs
  56. system target
  57. (rakudo (default-rakudo))
  58. (prove6 (default-prove6))
  59. (zef (default-zef))
  60. (with-prove6? #t)
  61. (with-zef? #t)
  62. #:allow-other-keys
  63. #:rest arguments)
  64. "Return a bag for NAME."
  65. (define private-keywords
  66. '(#:source #:target #:rakudo #:prove6 #:zef #:inputs #:native-inputs))
  67. (and (not target) ;XXX: no cross-compilation
  68. (bag
  69. (name name)
  70. (system system)
  71. (host-inputs `(,@(if source
  72. `(("source" ,source))
  73. '())
  74. ,@inputs
  75. ;; Keep the standard inputs of 'gnu-build-system'.
  76. ,@(standard-packages)))
  77. (build-inputs `(("rakudo" ,rakudo)
  78. ,@(if with-prove6?
  79. `(("perl6-tap-harness" ,prove6)
  80. ,@(if with-zef?
  81. `(("perl6-zef" ,zef))
  82. '()))
  83. '())
  84. ,@native-inputs))
  85. (outputs outputs)
  86. (build rakudo-build)
  87. (arguments (strip-keyword-arguments private-keywords arguments)))))
  88. (define* (rakudo-build store name inputs
  89. #:key
  90. (search-paths '())
  91. (tests? #t)
  92. (phases '(@ (guix build rakudo-build-system)
  93. %standard-phases))
  94. (outputs '("out"))
  95. (system (%current-system))
  96. (guile #f)
  97. (with-zef? #t)
  98. (with-prove6? #t)
  99. (imported-modules %rakudo-build-system-modules)
  100. (modules '((guix build rakudo-build-system)
  101. (guix build utils))))
  102. "Build SOURCE using PERL6, and with INPUTS."
  103. (define builder
  104. `(begin
  105. (use-modules ,@modules)
  106. (rakudo-build #:name ,name
  107. #:source ,(match (assoc-ref inputs "source")
  108. (((? derivation? source))
  109. (derivation->output-path source))
  110. ((source)
  111. source)
  112. (source
  113. source))
  114. #:search-paths ',(map search-path-specification->sexp
  115. search-paths)
  116. #:phases ,phases
  117. #:system ,system
  118. #:tests? ,tests?
  119. #:outputs %outputs
  120. #:inputs %build-inputs)))
  121. (define guile-for-build
  122. (match guile
  123. ((? package?)
  124. (package-derivation store guile system #:graft? #f))
  125. (#f ; the default
  126. (let* ((distro (resolve-interface '(gnu packages commencement)))
  127. (guile (module-ref distro 'guile-final)))
  128. (package-derivation store guile system #:graft? #f)))))
  129. (build-expression->derivation store name builder
  130. #:system system
  131. #:inputs inputs
  132. #:modules imported-modules
  133. #:outputs outputs
  134. #:guile-for-build guile-for-build))
  135. (define rakudo-build-system
  136. (build-system
  137. (name 'rakudo)
  138. (description "The standard Rakudo build system")
  139. (lower lower)))
  140. ;;; rakudo.scm ends here