1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
3 ;;; Copyright © 2019 Gabriel Hondet <gabrielhondet@gmail.com>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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
29 ;; Builder-side code of the standard dune build procedure.
33 (define* (build #:key (build-flags '()) (jbuild? #f)
34 (use-make? #f) (package #f) #:allow-other-keys)
35 "Build the given package."
36 (let ((program (if jbuild? "jbuilder" "dune")))
37 (apply invoke program "build" "@install"
38 (append (if package (list "-p" package) '()) build-flags)))
41 (define* (check #:key (test-flags '()) (test-target "test") tests?
42 (jbuild? #f) (package #f) #:allow-other-keys)
43 "Test the given package."
45 (let ((program (if jbuild? "jbuilder" "dune")))
46 (apply invoke program "runtest" test-target
47 (append (if package (list "-p" package) '()) test-flags))))
50 (define* (install #:key outputs (install-target "install") (jbuild? #f)
51 (package #f) #:allow-other-keys)
52 "Install the given package."
53 (let ((out (assoc-ref outputs "out"))
54 (program (if jbuild? "jbuilder" "dune")))
55 (apply invoke program install-target "--prefix" out "--libdir"
56 (string-append out "/lib/ocaml/site-lib")
57 (if package (list package) '())))
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
65 (replace 'build build)
66 (replace 'check check)
67 (replace 'install install)))
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))
74 ;;; dune-build-system.scm ends here