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
| | ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; 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 gerbil-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
#:use-module (guix build union)
#:use-module (guix build utils)
#:use-module (srfi srfi-26)
#:export (%standard-phases
gerbil-build))
;;; Commentary:
;;;
;;; Build-side code for building Gerbil packages.
;;;
;;; Something to note is that there is no standard way to run tests
;;; for Gerbil packages, so there is not `check' phase by default.
;;;
;;; Code:
(define (gerbil-package? name)
"Whether NAME is a Gerbil package."
(string-prefix? "gerbil-" name))
(define (gerbil-load-path inputs)
"Given an alist of inputs, INPUTS, return a list of directories to add
to the GERBIL_LOADPTH environment variable."
(let* ((labels (map car inputs))
(gerbil-packages (filter gerbil-package? labels)))
(map (cut string-append <> "/lib/gerbil")
gerbil-packages)))
(define* (setup-gerbil-environment #:key inputs #:allow-other-keys)
;; This is where the compiled modules will end up.
(setenv "GERBIL_PATH" (string-append (getcwd) "/.build"))
;; Where to look for other Gerbil modules.
(setenv "GERBIL_LOADPATH" (string-join (gerbil-load-path inputs) ":")))
(define* (build #:key build-flags #:allow-other-keys)
;; The build.ss script contians the build instructions.
(apply invoke "./build.ss" build-flags))
(define* (install #:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(mkdir-p (string-append out "/lib/gerbil"))
(copy-recursively ".build/lib" (string-append out "/lib/gerbil"))
(copy-recursively ".build/bin" (string-append out "/bin"))))
(define %standard-phases
(modify-phases gnu:%standard-phases
(delete 'bootstrap)
(delete 'configure)
(add-after 'unpack 'setup-gerbil-environment setup-gerbil-environment)
(replace 'build build)
(delete 'check)
(replace 'install install)))
(define* (gerbil-build #:key (phases %standard-phases)
#:allow-other-keys #:rest args)
"Build the given Gerbil packages, applying all of PHASES in order."
(apply gnu:gnu-build #:phases phases args))
|