dune-build-system.scm 2.8 KB

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