1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
| | ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix build rakudo-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
#:use-module (guix build utils)
#:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (%standard-phases
rakudo-build))
;; Commentary:
;;
;; Builder-side code of the standard Rakudo package build procedure.
;;
;; Code:
(define* (check #:key tests? inputs with-prove6? #:allow-other-keys)
(if (and tests? (assoc-ref inputs "perl6-tap-harness"))
;(if (and tests? with-prove6?)
(invoke "prove6" "-I=lib" "t/")
(format #t "test suite not run~%"))
#t)
(define* (install #:key inputs outputs with-zef? #:allow-other-keys)
"Install a given Perl6 package."
(let* ((out (assoc-ref outputs "out"))
(perl6 (string-append out "/share/perl6")))
(if (assoc-ref inputs "perl6-zef")
;(if with-zef?
(begin
(let ((zef (string-append (assoc-ref inputs "perl6-zef")
"/bin/zef")))
(setenv "HOME" (getcwd))
(mkdir-p perl6)
(invoke zef "install" "--verbose" "."
;; Don't install any of the following:
"--/depends" "--/build-depends" "--/test-depends"
(string-append "--install-to=" perl6))
(delete-file (string-append perl6 "/repo.lock")))
#t)
(begin
(let ((inst (string-append (assoc-ref inputs "rakudo")
"/share/perl6/tools/install-dist.p6")))
(setenv "RAKUDO_RERESOLVE_DEPENDENCIES" "0")
(setenv "RAKUDO_MODULE_DEBUG" "1") ; be verbose while building
(invoke inst (string-append "--to=" perl6) "--for=site"))))))
(define* (install-libs #:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(lock "lib/.precomp/.lock"))
(when (file-exists? lock)
(delete-file "lib/.precomp/.lock"))
(copy-recursively "lib" (string-append out "/share/perl6/lib"))
#t))
(define* (install-bins #:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(when (file-exists? "bin")
(for-each (lambda (file)
(install-file file (string-append out "/bin"))
(chmod (string-append out "/" file) #o555))
(find-files "bin" ".*")))
(when (file-exists? "sbin")
(for-each (lambda (file)
(install-file file (string-append out "/sbin"))
(chmod (string-append out "/" file) #o555))
(find-files "sbin" ".*")))
#t))
(define* (install-resources #:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(when (file-exists? "resources")
(copy-recursively "resources"
(string-append out "/share/perl6/resources")))
#t))
(define* (wrap #:key inputs outputs #:allow-other-keys)
(define (list-of-files dir)
(map (cut string-append dir "/" <>)
(or (scandir dir (lambda (f)
(let ((s (stat (string-append dir "/" f))))
(and (eq? 'regular (stat:type s))
(not (wrapped-program? f))))))
'())))
(define bindirs
(append-map (match-lambda
((_ . dir)
(list (string-append dir "/bin")
(string-append dir "/sbin"))))
outputs))
;; Do not require bash to be present in the package inputs
;; even when there is nothing to wrap.
;; Also, calculate (sh) only once to prevent some I/O.
(define %sh (delay (search-input-file inputs "bin/bash")))
(define (sh) (force %sh))
(let* ((out (assoc-ref outputs "out"))
(var `("PERL6LIB" "," prefix
,(cons (string-append out "/share/perl6/lib,"
out "/share/perl6/site/lib,"
out "/share/perl6/vendor/lib")
(search-path-as-string->list
(or (getenv "PERL6LIB") "") #\,)))))
(for-each (lambda (dir)
(let ((files (list-of-files dir)))
(for-each (cut wrap-program <> #:sh (sh) var)
files)))
bindirs)
#t))
(define %standard-phases
;; No need for 'bootstrap, 'configure or 'build.
(modify-phases gnu:%standard-phases
(delete 'bootstrap)
(delete 'configure)
(delete 'build)
(replace 'check check)
(replace 'install install)
(add-before 'install 'install-lib-dir install-libs)
(add-after 'install-lib-dir 'install-resources install-resources)
(add-after 'install-resources 'install-binaries install-bins)
;; needs to be after 'install-binaries and all 'install phases
(add-after 'install 'wrap wrap)))
(define* (rakudo-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
"Build the given Perl6 package, applying all of PHASES in order."
(apply gnu:gnu-build
#:inputs inputs #:phases phases
args))
;;; rakudo-build-system.scm ends here
|