dune-build-system.scm 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. ;;; Copyright © 2021 pukkamustard <pukkamustard@posteo.net>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; 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
  25. dune-build))
  26. ;; Commentary:
  27. ;;
  28. ;; Builder-side code of the standard dune build procedure.
  29. ;;
  30. ;; Code:
  31. (define* (build #:key (build-flags '()) (jbuild? #f)
  32. (use-make? #f) (package #f) (dune-release-flags '())
  33. #:allow-other-keys)
  34. "Build the given package."
  35. (let ((program (if jbuild? "jbuilder" "dune")))
  36. (apply invoke program "build" "@install"
  37. (append (if package (list "-p" package)
  38. dune-release-flags)
  39. build-flags)))
  40. #t)
  41. (define* (check #:key (test-flags '()) tests?
  42. (jbuild? #f) (package #f) (dune-release-flags '())
  43. #:allow-other-keys)
  44. "Test the given package."
  45. (when tests?
  46. (let ((program (if jbuild? "jbuilder" "dune")))
  47. (apply invoke program "runtest"
  48. (append (if package (list "-p" package)
  49. dune-release-flags)
  50. test-flags))))
  51. #t)
  52. (define* (install #:key outputs (install-target "install") (jbuild? #f)
  53. (package #f) #:allow-other-keys)
  54. "Install the given package."
  55. (let ((out (assoc-ref outputs "out"))
  56. (program (if jbuild? "jbuilder" "dune")))
  57. (apply invoke program install-target "--prefix" out "--libdir"
  58. (string-append out "/lib/ocaml/site-lib")
  59. (if package (list package) '())))
  60. #t)
  61. (define %standard-phases
  62. ;; Everything is as with the GNU Build System except for the `configure'
  63. ;; , `build', `check' and `install' phases.
  64. (modify-phases ocaml:%standard-phases
  65. (delete 'configure)
  66. (replace 'build build)
  67. (replace 'check check)
  68. (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))
  73. ;;; dune-build-system.scm ends here