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