Commit | Line | Data |
---|---|---|
4e4c3114 EF |
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 | ||
19 | (define-module (guix build-system rakudo) | |
20 | #:use-module (guix store) | |
21 | #:use-module (guix utils) | |
22 | #:use-module (guix derivations) | |
23 | #:use-module (guix search-paths) | |
24 | #:use-module (guix build-system) | |
25 | #:use-module (guix build-system gnu) | |
26 | #:use-module (guix packages) | |
27 | #:use-module (ice-9 match) | |
28 | #:export (%rakudo-build-system-modules | |
29 | rakudo-build | |
30 | rakudo-build-system)) | |
31 | ||
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 | ||
40 | (define %rakudo-build-system-modules | |
41 | ;; Build-side modules imported by default. | |
42 | `((guix build rakudo-build-system) | |
43 | ,@%gnu-build-system-modules)) | |
44 | ||
45 | (define (default-rakudo) | |
46 | "Return the default Rakudo package." | |
47 | ||
48 | ;; Do not use `@' to avoid introducing circular dependencies. | |
49 | (let ((module (resolve-interface '(gnu packages perl6)))) | |
50 | (module-ref module 'rakudo))) | |
51 | ||
52 | (define (default-prove6) | |
53 | "Return the default perl6-tap-harness package for tests." | |
54 | (let ((module (resolve-interface '(gnu packages perl6)))) | |
55 | (module-ref module 'perl6-tap-harness))) | |
56 | ||
57 | (define (default-zef) | |
58 | "Return the default perl6-zef package." | |
59 | (let ((module (resolve-interface '(gnu packages perl6)))) | |
60 | (module-ref module 'perl6-zef))) | |
61 | ||
62 | (define* (lower name | |
63 | #:key source inputs native-inputs outputs | |
64 | system target | |
65 | (rakudo (default-rakudo)) | |
66 | (prove6 (default-prove6)) | |
67 | (zef (default-zef)) | |
68 | (with-prove6? #t) | |
69 | (with-zef? #t) | |
70 | #:allow-other-keys | |
71 | #:rest arguments) | |
72 | "Return a bag for NAME." | |
73 | (define private-keywords | |
74 | '(#:source #:target #:rakudo #:prove6 #:zef #:inputs #:native-inputs)) | |
75 | ||
76 | (and (not target) ;XXX: no cross-compilation | |
77 | (bag | |
78 | (name name) | |
79 | (system system) | |
80 | (host-inputs `(,@(if source | |
81 | `(("source" ,source)) | |
82 | '()) | |
83 | ,@inputs | |
84 | ||
85 | ;; Keep the standard inputs of 'gnu-build-system'. | |
86 | ,@(standard-packages))) | |
87 | (build-inputs `(("rakudo" ,rakudo) | |
88 | ,@(if with-prove6? | |
89 | `(("perl6-tap-harness" ,prove6) | |
90 | ,@(if with-zef? | |
91 | `(("perl6-zef" ,zef)) | |
92 | '())) | |
93 | '()) | |
94 | ,@native-inputs)) | |
95 | (outputs outputs) | |
96 | (build rakudo-build) | |
97 | (arguments (strip-keyword-arguments private-keywords arguments))))) | |
98 | ||
99 | (define* (rakudo-build store name inputs | |
100 | #:key | |
101 | (search-paths '()) | |
102 | (tests? #t) | |
103 | (phases '(@ (guix build rakudo-build-system) | |
104 | %standard-phases)) | |
105 | (outputs '("out")) | |
106 | (system (%current-system)) | |
107 | (guile #f) | |
108 | (with-zef? #t) | |
109 | (with-prove6? #t) | |
110 | (imported-modules %rakudo-build-system-modules) | |
111 | (modules '((guix build rakudo-build-system) | |
112 | (guix build utils)))) | |
113 | "Build SOURCE using PERL6, and with INPUTS." | |
114 | (define builder | |
115 | `(begin | |
116 | (use-modules ,@modules) | |
117 | (rakudo-build #:name ,name | |
118 | #:source ,(match (assoc-ref inputs "source") | |
119 | (((? derivation? source)) | |
120 | (derivation->output-path source)) | |
121 | ((source) | |
122 | source) | |
123 | (source | |
124 | source)) | |
125 | #:search-paths ',(map search-path-specification->sexp | |
126 | search-paths) | |
127 | #:phases ,phases | |
128 | #:system ,system | |
129 | #:tests? ,tests? | |
130 | #:outputs %outputs | |
131 | #:inputs %build-inputs))) | |
132 | ||
133 | (define guile-for-build | |
134 | (match guile | |
135 | ((? package?) | |
136 | (package-derivation store guile system #:graft? #f)) | |
137 | (#f ; the default | |
138 | (let* ((distro (resolve-interface '(gnu packages commencement))) | |
139 | (guile (module-ref distro 'guile-final))) | |
140 | (package-derivation store guile system #:graft? #f))))) | |
141 | ||
142 | (build-expression->derivation store name builder | |
143 | #:system system | |
144 | #:inputs inputs | |
145 | #:modules imported-modules | |
146 | #:outputs outputs | |
147 | #:guile-for-build guile-for-build)) | |
148 | ||
149 | (define rakudo-build-system | |
150 | (build-system | |
151 | (name 'rakudo) | |
152 | (description "The standard Rakudo build system") | |
153 | (lower lower))) | |
154 | ||
155 | ;;; rakudo.scm ends here |