Commit | Line | Data |
---|---|---|
6e8986c8 JL |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu> | |
625a3daa | 3 | ;;; Copyright © 2019 Gabriel Hondet <gabrielhondet@gmail.com> |
6e8986c8 JL |
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 dune-build-system) | |
21 | #:use-module ((guix build ocaml-build-system) #:prefix ocaml:) | |
22 | #:use-module (guix build utils) | |
23 | #:use-module (ice-9 match) | |
24 | #:export (%standard-phases | |
25 | dune-build)) | |
26 | ||
27 | ;; Commentary: | |
28 | ;; | |
29 | ;; Builder-side code of the standard dune build procedure. | |
30 | ;; | |
31 | ;; Code: | |
32 | ||
33 | (define* (build #:key (build-flags '()) (jbuild? #f) | |
78b3748c | 34 | (use-make? #f) (package #f) #:allow-other-keys) |
6e8986c8 JL |
35 | "Build the given package." |
36 | (let ((program (if jbuild? "jbuilder" "dune"))) | |
78b3748c JL |
37 | (apply invoke program "build" "@install" |
38 | (append (if package (list "-p" package) '()) build-flags))) | |
6e8986c8 JL |
39 | #t) |
40 | ||
41 | (define* (check #:key (test-flags '()) (test-target "test") tests? | |
78b3748c | 42 | (jbuild? #f) (package #f) #:allow-other-keys) |
6e8986c8 JL |
43 | "Test the given package." |
44 | (when tests? | |
45 | (let ((program (if jbuild? "jbuilder" "dune"))) | |
78b3748c JL |
46 | (apply invoke program "runtest" test-target |
47 | (append (if package (list "-p" package) '()) test-flags)))) | |
6e8986c8 JL |
48 | #t) |
49 | ||
50 | (define* (install #:key outputs (install-target "install") (jbuild? #f) | |
78b3748c | 51 | (package #f) #:allow-other-keys) |
6e8986c8 JL |
52 | "Install the given package." |
53 | (let ((out (assoc-ref outputs "out")) | |
54 | (program (if jbuild? "jbuilder" "dune"))) | |
78b3748c JL |
55 | (apply invoke program install-target "--prefix" out "--libdir" |
56 | (string-append out "/lib/ocaml/site-lib") | |
57 | (if package (list package) '()))) | |
6e8986c8 JL |
58 | #t) |
59 | ||
60 | (define %standard-phases | |
61 | ;; Everything is as with the GNU Build System except for the `configure' | |
62 | ;; , `build', `check' and `install' phases. | |
63 | (modify-phases ocaml:%standard-phases | |
64 | (delete 'configure) | |
65 | (replace 'build build) | |
66 | (replace 'check check) | |
67 | (replace 'install install))) | |
68 | ||
69 | (define* (dune-build #:key inputs (phases %standard-phases) | |
70 | #:allow-other-keys #:rest args) | |
71 | "Build the given package, applying all of PHASES in order." | |
72 | (apply ocaml:ocaml-build #:inputs inputs #:phases phases args)) | |
73 | ||
74 | ;;; dune-build-system.scm ends here |