GNU bug report logs - #33437
[PATCH] Add dune-build-system

Previous Next

Package: guix-patches;

Reported by: Julien Lepiller <julien <at> lepiller.eu>

Date: Mon, 19 Nov 2018 22:27:02 UTC

Severity: normal

Tags: patch

Done: Julien Lepiller <julien <at> lepiller.eu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33437 in the body.
You can then email your comments to 33437 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:27:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Julien Lepiller <julien <at> lepiller.eu>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 19 Nov 2018 22:27:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: guix-patches <at> gnu.org
Subject: [PATCH] Add dune-build-system
Date: Mon, 19 Nov 2018 23:25:37 +0100
Hi, here is a small patch series to add dune-build-system and convert a
few packages to it.




Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:02 GMT) Full text and rfc822 format available.

Message #8 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 01/10] build: Add dune-build-system.
Date: Mon, 19 Nov 2018 23:28:12 +0100
* guix/build/dune-build-system.scm,
  guix/build-system/dune.scm: New files.
* Makefile.am (MODULES): Add them.
* doc/guix.texi (Build Systems): Document dune-build-system.
* guix/build-system/ocaml.scm (lower, default-findlib, default-ocaml): Export
them.
(package-with-explicit-ocaml): Also transform packages built with
dune-build-system.
---
 Makefile.am                      |   2 +
 doc/guix.texi                    |  22 +++++
 guix/build-system/dune.scm       | 158 +++++++++++++++++++++++++++++++
 guix/build-system/ocaml.scm      |  16 +++-
 guix/build/dune-build-system.scm |  69 ++++++++++++++
 5 files changed, 265 insertions(+), 2 deletions(-)
 create mode 100644 guix/build-system/dune.scm
 create mode 100644 guix/build/dune-build-system.scm

diff --git a/Makefile.am b/Makefile.am
index c63b65ba5..956ba8622 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,6 +102,7 @@ MODULES =					\
   guix/build-system/cargo.scm			\
   guix/build-system/cmake.scm			\
   guix/build-system/dub.scm			\
+  guix/build-system/dune.scm			\
   guix/build-system/emacs.scm			\
   guix/build-system/font.scm			\
   guix/build-system/go.scm			\
@@ -139,6 +140,7 @@ MODULES =					\
   guix/build/cargo-build-system.scm		\
   guix/build/cmake-build-system.scm		\
   guix/build/dub-build-system.scm		\
+  guix/build/dune-build-system.scm		\
   guix/build/emacs-build-system.scm		\
   guix/build/meson-build-system.scm		\
   guix/build/minify-build-system.scm		\
diff --git a/doc/guix.texi b/doc/guix.texi
index a9c6e975a..51a3b191b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4412,6 +4412,28 @@ debugging information''), which roughly means that code is compiled with
 @code{-O2 -g}, as is the case for Autoconf-based packages by default.
 @end defvr
 
+@defvr {Scheme Variable} dune-build-system
+This variable is exported by @code{(guix build-system dune)}.  It
+supports builds of packaes using Dune, a build tool for the
+@uref{https://ocaml.org, OCaml programming language}.  It is implemented
+as an extension of the @code{ocaml-build-system} which is describe below.
+As such, the @code{#:ocaml} and @code{#:findlib} parameters can be passed
+to this build system.
+
+It automically adds the @code{dune} package to the set of inputs.
+Which package is used can be specified with the @code{#:dune}
+parameter.
+
+The @code{'configure} phase is removed as dune packages typically
+don't need to be configured.  The @code{#:build-flags} parameter is
+taken as a list of flags passed to the @code{dune} command during the
+build.
+
+The @code{#:legacy?} parameter can be passed to use the @code{jbuild}
+command instead of the more recent @code{dune} command while building
+a package.  Its default value is @code{#f}.
+@end defvr
+
 @defvr {Scheme Variable} go-build-system
 This variable is exported by @code{(guix build-system go)}.  It
 implements a build procedure for Go packages using the standard
diff --git a/guix/build-system/dune.scm b/guix/build-system/dune.scm
new file mode 100644
index 000000000..1937c7df4
--- /dev/null
+++ b/guix/build-system/dune.scm
@@ -0,0 +1,158 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016, 2017, 2018 Julien Lepiller <julien <at> lepiller.eu>
+;;; Copyright © 2017 Ben Woodcroft <donttrustben <at> gmail.com>
+;;;
+;;; 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-system dune)
+  #:use-module (guix store)
+  #:use-module (guix utils)
+  #:use-module (guix derivations)
+  #:use-module (guix search-paths)
+  #:use-module (guix build-system)
+  #:use-module ((guix build-system gnu) #:prefix gnu:)
+  #:use-module ((guix build-system ocaml) #:prefix ocaml:)
+  #:use-module (guix packages)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1)
+  #:export (%dune-build-system-modules
+            dune-build
+            dune-build-system))
+
+;; Commentary:
+;;
+;; Standard build procedure for packages using dune. This is implemented as an
+;; extension of `ocaml-build-system'.
+;;
+;; Code:
+
+(define %dune-build-system-modules
+  ;; Build-side modules imported by default.
+  `((guix build dune-build-system)
+    ,@ocaml:%ocaml-build-system-modules))
+
+(define (default-dune)
+  "Return the default OCaml package."
+
+  ;; Do not use `@' to avoid introducing circular dependencies.
+  (let ((module (resolve-interface '(gnu packages ocaml))))
+    (module-ref module 'dune)))
+
+(define* (lower name
+                #:key source inputs native-inputs outputs system target
+                (dune (default-dune))
+                (ocaml (ocaml:default-ocaml))
+                (findlib (ocaml:default-findlib))
+                #:allow-other-keys
+                #:rest arguments)
+  "Return a bag for NAME."
+  (define private-keywords
+    '(#:source #:target #:dune #:findlib #:ocaml #:inputs #:native-inputs))
+
+  (and (not target)                               ;XXX: no cross-compilation
+       (let ((base (ocaml:lower name
+                                #:source source
+                                #:inputs inputs
+                                #:native-inputs native-inputs
+                                #:outputs outputs
+                                #:system system
+                                #:target target
+                                #:ocaml ocaml
+                                #:findlib findlib
+                                arguments)))
+         (bag
+           (inherit base)
+           (build-inputs `(("dune" ,dune)
+                           ,@(bag-build-inputs base)))
+           (build dune-build)
+           (arguments (strip-keyword-arguments private-keywords arguments))))))
+
+(define* (dune-build store name inputs
+                     #:key (guile #f)
+                     (outputs '("out"))
+                     (search-paths '())
+                     (build-flags ''())
+                     (out-of-source? #t)
+                     (legacy? #f)
+                     (tests? #t)
+                     (test-flags ''())
+                     (test-target "test")
+                     (install-target "install")
+                     (validate-runpath? #t)
+                     (patch-shebangs? #t)
+                     (strip-binaries? #t)
+                     (strip-flags ''("--strip-debug"))
+                     (strip-directories ''("lib" "lib64" "libexec"
+                                           "bin" "sbin"))
+                     (phases '(@ (guix build dune-build-system)
+                                 %standard-phases))
+                     (system (%current-system))
+                     (imported-modules %dune-build-system-modules)
+                     (modules '((guix build dune-build-system)
+                                (guix build utils))))
+  "Build SOURCE using OCAML, and with INPUTS. This assumes that SOURCE
+provides a 'setup.ml' file as its build system."
+  (define builder
+    `(begin
+       (use-modules ,@modules)
+       (dune-build #:source ,(match (assoc-ref inputs "source")
+                               (((? derivation? source))
+                                (derivation->output-path source))
+                               ((source)
+                                source)
+                               (source
+                                source))
+                   #:system ,system
+                   #:outputs %outputs
+                   #:inputs %build-inputs
+                   #:search-paths ',(map search-path-specification->sexp
+                                         search-paths)
+                   #:phases ,phases
+                   #:test-flags ,test-flags
+                   #:build-flags ,build-flags
+                   #:out-of-source? ,out-of-source?
+                   #:legacy? ,legacy?
+                   #:tests? ,tests?
+                   #:test-target ,test-target
+                   #:install-target ,install-target
+                   #:validate-runpath? ,validate-runpath?
+                   #:patch-shebangs? ,patch-shebangs?
+                   #:strip-binaries? ,strip-binaries?
+                   #:strip-flags ,strip-flags
+                   #:strip-directories ,strip-directories)))
+
+  (define guile-for-build
+    (match guile
+      ((? package?)
+       (package-derivation store guile system #:graft? #f))
+      (#f                                         ; the default
+       (let* ((distro (resolve-interface '(gnu packages commencement)))
+              (guile  (module-ref distro 'guile-final)))
+         (package-derivation store guile system #:graft? #f)))))
+
+  (build-expression->derivation store name builder
+                                #:system system
+                                #:inputs inputs
+                                #:modules imported-modules
+                                #:outputs outputs
+                                #:guile-for-build guile-for-build))
+
+(define dune-build-system
+  (build-system
+    (name 'dune)
+    (description "The standard Dune build system")
+    (lower lower)))
+
+;;; dune.scm ends here
diff --git a/guix/build-system/ocaml.scm b/guix/build-system/ocaml.scm
index e5b715f55..07c69fac7 100644
--- a/guix/build-system/ocaml.scm
+++ b/guix/build-system/ocaml.scm
@@ -31,6 +31,9 @@
             package-with-ocaml4.02
             strip-ocaml4.01-variant
             strip-ocaml4.02-variant
+            default-findlib
+            default-ocaml
+            lower
             ocaml-build
             ocaml-build-system))
 
@@ -76,6 +79,13 @@
   (let ((module (resolve-interface '(gnu packages ocaml))))
     (module-ref module 'ocaml-findlib)))
 
+(define (default-dune-build-system)
+  "Return the dune-build-system."
+
+  ;; Do not use `@' to avoid introducing circular dependencies.
+  (let ((module (resolve-interface '(guix build-system dune))))
+    (module-ref module 'dune-build-system)))
+
 (define (default-ocaml4.01)
   (let ((ocaml (resolve-interface '(gnu packages ocaml))))
     (module-ref ocaml 'ocaml-4.01)))
@@ -119,7 +129,8 @@ pre-defined variants."
       => force)
 
      ;; Otherwise build the new package object graph.
-     ((eq? (package-build-system p) ocaml-build-system)
+     ((or (eq? (package-build-system p) ocaml-build-system)
+          (eq? (package-build-system p) (default-dune-build-system)))
       (package
         (inherit p)
         (location (package-location p))
@@ -138,7 +149,8 @@ pre-defined variants."
      (else p)))
 
   (define (cut? p)
-    (or (not (eq? (package-build-system p) ocaml-build-system))
+    (or (not (or (eq? (package-build-system p) ocaml-build-system)
+                 (eq? (package-build-system p) (default-dune-build-system))))
         (package-variant p)))
 
   (package-mapping transform cut?))
diff --git a/guix/build/dune-build-system.scm b/guix/build/dune-build-system.scm
new file mode 100644
index 000000000..08a63d2ab
--- /dev/null
+++ b/guix/build/dune-build-system.scm
@@ -0,0 +1,69 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2018 Julien Lepiller <julien <at> lepiller.eu>
+;;;
+;;; 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 dune-build-system)
+  #:use-module ((guix build ocaml-build-system) #:prefix ocaml:)
+  #:use-module (guix build utils)
+  #:use-module (ice-9 match)
+  #:export (%standard-phases
+            dune-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard dune build procedure.
+;;
+;; Code:
+
+(define* (build #:key (build-flags '()) (legacy? #f)
+                (use-make? #f) #:allow-other-keys)
+  "Build the given package."
+  (let ((program (if legacy? "jbuilder" "dune")))
+    (apply invoke program "build" "@install" build-flags))
+  #t)
+
+(define* (check #:key (test-flags '()) (test-target "test") tests?
+                  (legacy? #f) #:allow-other-keys)
+  "Test the given package."
+  (when tests?
+    (let ((program (if legacy? "jbuilder" "dune")))
+      (apply invoke program "runtest" test-target test-flags)))
+  #t)
+
+(define* (install #:key outputs (install-target "install") (legacy? #f)
+                  #:allow-other-keys)
+  "Install the given package."
+  (let ((out (assoc-ref outputs "out"))
+        (program (if legacy? "jbuilder" "dune")))
+    (invoke program install-target "--prefix" out))
+  #t)
+
+(define %standard-phases
+  ;; Everything is as with the GNU Build System except for the `configure'
+  ;; , `build', `check' and `install' phases.
+  (modify-phases ocaml:%standard-phases
+    (delete 'configure)
+    (replace 'build build)
+    (replace 'check check)
+    (replace 'install install)))
+
+(define* (dune-build #:key inputs (phases %standard-phases)
+                     #:allow-other-keys #:rest args)
+  "Build the given package, applying all of PHASES in order."
+  (apply ocaml:ocaml-build #:inputs inputs #:phases phases args))
+
+;;; dune-build-system.scm ends here
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:02 GMT) Full text and rfc822 format available.

Message #11 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 02/10] gnu: ocaml-migrate-parsetree: Use dune-build-system.
Date: Mon, 19 Nov 2018 23:28:13 +0100
* gnu/packages/ocaml.scm (ocaml-migrate-parsetree): Use
dune-build-system.
---
 gnu/packages/ocaml.scm | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index e1323582a..a1f6adc8b 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -62,6 +62,7 @@
   #:use-module (gnu packages web-browsers)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg)
+  #:use-module (guix build-system dune)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system ocaml)
   #:use-module (guix download)
@@ -1536,26 +1537,13 @@ following a very simple s-expression syntax.")
               (sha256
                (base32
                 "01zjp1q4hryqaxv4apkjd868fycz2kf887r6lkb6x2a545h1lh7f"))))
-    (build-system ocaml-build-system)
+    (build-system dune-build-system)
     (arguments
      `(#:tests? #f
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'build
-           (lambda _
-             (invoke "jbuilder" "build" "@install")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "jbuilder" "install"
-                     "--prefix" (assoc-ref outputs "out"))
-             #t)))))
+       #:legacy? #t))
     (propagated-inputs
      `(("ocamlbuild" ,ocamlbuild)
        ("ocaml-result" ,ocaml-result)))
-    (native-inputs
-     `(("dune" ,dune)))
     (home-page "https://github.com/ocaml-ppx/ocaml-migrate-parsetree")
     (synopsis "OCaml parsetree convertor")
     (description "This library converts between parsetrees of different OCaml
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:02 GMT) Full text and rfc822 format available.

Message #14 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 03/10] gnu: ocaml-ppx-tools-versioned: Use dune-build-system.
Date: Mon, 19 Nov 2018 23:28:14 +0100
* gnu/packages/ocaml.scm (ocaml-ppx-tools-versioned): Use
dune-build-system.  Remove duplicate definition.
---
 gnu/packages/ocaml.scm | 55 ++----------------------------------------
 1 file changed, 2 insertions(+), 53 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index a1f6adc8b..fe8871152 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -1564,60 +1564,9 @@ functions to the next and/or previous version.")
               (sha256
                (base32
                 "1x2xfjpkzbcz4rza1d7gh3ipliw6jqfcklbsln82v3561qgkqgmh"))))
-    (build-system ocaml-build-system)
+    (build-system dune-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'build
-           (lambda _
-             (invoke "dune" "build" "@install")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "dune" "install"
-                     "--prefix" (assoc-ref outputs "out"))
-             #t)))))
-    (native-inputs
-     `(("dune" ,dune)))
-    (propagated-inputs
-     `(("ocaml-migrate-parsetree" ,ocaml-migrate-parsetree)))
-    (home-page "https://github.com/let-def/ppx_tools_versioned")
-    (synopsis "Variant of ppx_tools")
-    (description "This package is a variant of ppx_tools based on
-ocaml-migrate-parsetree")
-    (license license:expat)))
-
-(define-public ocaml-ppx-tools-versioned
-  (package
-    (name "ocaml-ppx-tools-versioned")
-    (version "5.2.1")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append "https://github.com/ocaml-ppx/"
-                                  "ppx_tools_versioned/archive/"
-                                  version ".tar.gz"))
-              (file-name (string-append name "-" version ".tar.gz"))
-              (sha256
-               (base32
-                "1x2xfjpkzbcz4rza1d7gh3ipliw6jqfcklbsln82v3561qgkqgmh"))))
-    (build-system ocaml-build-system)
-    (arguments
-     `(#:tests? #f
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'build
-           (lambda _
-             (invoke "dune" "build" "@install")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "dune" "install"
-                     "--prefix" (assoc-ref outputs "out"))
-             #t)))))
-    (native-inputs
-     `(("dune" ,dune)))
+     `(#:test-target "."))
     (propagated-inputs
      `(("ocaml-migrate-parsetree" ,ocaml-migrate-parsetree)))
     (home-page "https://github.com/let-def/ppx_tools_versioned")
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:03 GMT) Full text and rfc822 format available.

Message #17 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 04/10] gnu: ocaml-bitstring: Use dune-build-system.
Date: Mon, 19 Nov 2018 23:28:15 +0100
* gnu/packages/ocaml.scm (ocaml-bitstring): Use dune-build-system.
(ocaml4.02-bitstring)[build-system]: Use ocaml-build-system explicitly.
---
 gnu/packages/ocaml.scm | 95 +++++++++++++++++++-----------------------
 1 file changed, 42 insertions(+), 53 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index fe8871152..bf4fcc47f 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -1587,31 +1587,19 @@ ocaml-migrate-parsetree")
               (sha256
                (base32
                 "15jjk2pq1vx311gl49s5ag6x5y0654x35w75z07g7kr2q334hqps"))))
-    (build-system ocaml-build-system)
+    (build-system dune-build-system)
     (native-inputs
      `(("camlp4" ,camlp4)
        ("time" ,time)
        ("autoconf" ,autoconf)
        ("automake" ,automake)
-       ("bisect" ,ocaml-bisect)
-       ("dune" ,dune)))
+       ("bisect" ,ocaml-bisect)))
     (propagated-inputs
      `(("camlp4" ,camlp4)
        ("ocaml-ppx-tools-versioned" ,ocaml-ppx-tools-versioned)))
     (arguments
      `(#:tests? #f; Tests fail to build
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'build
-           (lambda _
-             (invoke "jbuilder" "build" "@install")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "dune" "install"
-                     "--prefix" (assoc-ref outputs "out"))
-             #t)))))
+       #:legacy? #t))
     (properties
       `((ocaml4.02-variant . ,(delay ocaml4.02-bitstring))))
     (home-page "https://github.com/xguerin/bitstring")
@@ -1637,44 +1625,45 @@ powerful.")
                  (base32
                   "0vy8ibrxccii1jbsk5q6yh1kxjigqvi7lhhcmizvd5gfhf7mfyc8"))
                 (patches (search-patches "ocaml-bitstring-fix-configure.patch"))))
-    (arguments
-     `(#:ocaml ,ocaml-4.02
-       #:findlib ,ocaml4.02-findlib
-       #:configure-flags
-       (list "CAMLP4OF=camlp4of" "--enable-coverage")
-       #:make-flags
-       (list (string-append "BISECTLIB="
-                            (assoc-ref %build-inputs "bisect")
-                            "/lib/ocaml/site-lib")
-             (string-append "OCAMLCFLAGS=-g -I "
-                            (assoc-ref %build-inputs "camlp4")
-                            "/lib/ocaml/site-lib/camlp4 -I "
-                            "$(BISECTLIB)/bisect")
-             (string-append "OCAMLOPTFLAGS=-g -I "
-                            (assoc-ref %build-inputs "camlp4")
-                            "/lib/ocaml/site-lib/camlp4 -I "
-                            "$(BISECTLIB)/bisect"))
-       #:phases
-       (modify-phases %standard-phases
-         (add-after 'install 'link-lib
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (stubs (string-append out
-                                          "/lib/ocaml/site-lib/stubslibs"))
-                    (lib (string-append out
-                                        "/lib/ocaml/site-lib/bitstring")))
-               (mkdir-p stubs)
-               (symlink (string-append lib "/dllbitstring.so")
-                        (string-append stubs "/dllbitstring.so")))
-             #t))
-         (add-before 'configure 'fix-configure
-           (lambda* (#:key inputs #:allow-other-keys)
-             (substitute* "Makefile.in"
-               (("@abs_top_builddir@")
-                (string-append "@abs_top_builddir@:" (getenv "LIBRARY_PATH"))))
-             (substitute* "configure"
-               (("-/bin/sh") (string-append "-" (assoc-ref inputs "bash")
-                                            "/bin/sh"))))))))
+      (build-system ocaml-build-system)
+      (arguments
+       `(#:ocaml ,ocaml-4.02
+         #:findlib ,ocaml4.02-findlib
+         #:configure-flags
+         (list "CAMLP4OF=camlp4of" "--enable-coverage")
+         #:make-flags
+         (list (string-append "BISECTLIB="
+                              (assoc-ref %build-inputs "bisect")
+                              "/lib/ocaml/site-lib")
+               (string-append "OCAMLCFLAGS=-g -I "
+                              (assoc-ref %build-inputs "camlp4")
+                              "/lib/ocaml/site-lib/camlp4 -I "
+                              "$(BISECTLIB)/bisect")
+               (string-append "OCAMLOPTFLAGS=-g -I "
+                              (assoc-ref %build-inputs "camlp4")
+                              "/lib/ocaml/site-lib/camlp4 -I "
+                              "$(BISECTLIB)/bisect"))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'install 'link-lib
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (stubs (string-append out
+                                            "/lib/ocaml/site-lib/stubslibs"))
+                      (lib (string-append out
+                                          "/lib/ocaml/site-lib/bitstring")))
+                 (mkdir-p stubs)
+                 (symlink (string-append lib "/dllbitstring.so")
+                          (string-append stubs "/dllbitstring.so")))
+               #t))
+           (add-before 'configure 'fix-configure
+             (lambda* (#:key inputs #:allow-other-keys)
+               (substitute* "Makefile.in"
+                 (("@abs_top_builddir@")
+                  (string-append "@abs_top_builddir@:" (getenv "LIBRARY_PATH"))))
+               (substitute* "configure"
+                 (("-/bin/sh") (string-append "-" (assoc-ref inputs "bash")
+                                              "/bin/sh"))))))))
       (native-inputs
        `(("camlp4" ,camlp4-4.02)
          ("time" ,time)
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:03 GMT) Full text and rfc822 format available.

Message #20 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 05/10] gnu: ocaml-lwt: Use dune-build-system.
Date: Mon, 19 Nov 2018 23:28:16 +0100
* gnu/packages/ocaml.scm (ocaml-lwt): Use dune-build-system.
---
 gnu/packages/ocaml.scm | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index bf4fcc47f..c6ae4e78f 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -2133,26 +2133,18 @@ through Transport Layer Security (@dfn{TLS}) encrypted connections.")
         (file-name (string-append name "-" version ".tar.gz"))
         (sha256 (base32
                   "0mhh019bjkg5xfvpy1pxs4xdxb759fyydmgb6l4j0qww1qgr8klp"))))
-    (build-system ocaml-build-system)
+    (build-system dune-build-system)
     (arguments
      `(#:tests? #f; require lwt_ppx
+       #:legacy? #t
        #:phases
        (modify-phases %standard-phases
-         (replace 'configure
+         (add-before 'build 'configure
            (lambda _
              (invoke "ocaml" "src/util/configure.ml" "-use-libev" "true")
-             #t))
-         (replace 'build
-           (lambda _
-             (invoke "jbuilder" "build" "@install")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "jbuilder" "install" "--prefix" (assoc-ref outputs "out"))
              #t)))))
     (native-inputs
-     `(("dune" ,dune)
-       ("ocaml-cppo" ,ocaml-cppo)
+     `(("ocaml-cppo" ,ocaml-cppo)
        ("ocaml-migrate-parsetree" ,ocaml-migrate-parsetree)
        ("pkg-config" ,pkg-config)
        ("ppx-tools-versioned" ,ocaml-ppx-tools-versioned)))
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:04 GMT) Full text and rfc822 format available.

Message #23 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 06/10] gnu: ocaml-lwt-log: Use dune-build-system.
Date: Mon, 19 Nov 2018 23:28:17 +0100
* gnu/packages/ocaml.scm (ocaml-lwt-log): Use dune-build-system.
---
 gnu/packages/ocaml.scm | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index c6ae4e78f..5d322c273 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -2178,22 +2178,10 @@ locks or other synchronization primitives.")
         (file-name (string-append name "-" version ".tar.gz"))
         (sha256 (base32
                   "1lr62j2266pbsi54xmzsfvl2z7fi7smhak7fp1ybl8hssxwi6in2"))))
-    (build-system ocaml-build-system)
+    (build-system dune-build-system)
     (arguments
      `(#:tests? #f; require lwt_ppx
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'build
-           (lambda _
-             (invoke "jbuilder" "build" "@install")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "jbuilder" "install" "--prefix" (assoc-ref outputs "out"))
-             #t)))))
-    (native-inputs
-     `(("dune" ,dune)))
+       #:legacy? #t))
     (propagated-inputs
      `(("lwt" ,ocaml-lwt)))
     (home-page "https://github.com/aantron/lwt_log")
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:04 GMT) Full text and rfc822 format available.

Message #26 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 07/10] gnu: ocaml-cppo: Use dune-build-system.
Date: Mon, 19 Nov 2018 23:28:18 +0100
* gnu/packages/ocaml.scm (ocaml-cppo): Use dune-build-system.
---
 gnu/packages/ocaml.scm | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 5d322c273..fe844b82d 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -2995,24 +2995,12 @@ provide a tool that can be used to:
         (sha256 (base32
                   "1dkm3d5h6h56y937gcdk2wixlpzl59vv5pmiafglr89p20kf7gqf"))
         (file-name (string-append name "-" version ".tar.gz"))))
-    (build-system ocaml-build-system)
+    (build-system dune-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'build
-           (lambda _
-             (invoke "dune" "build" "@install" "--profile" "release")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "dune" "install"
-                     "--prefix" (assoc-ref outputs "out"))
-             #t)))
-       #:tests? #f))
+     `(#:tests? #f
+       #:build-flags (list "--profile" "release")))
     (native-inputs
-     `(("dune" ,dune)
-       ("ocamlbuild" ,ocamlbuild)))
+     `(("ocamlbuild" ,ocamlbuild)))
     (home-page "https://github.com/mjambon/cppo")
     (synopsis "Equivalent of the C preprocessor for OCaml programs")
     (description "Cppo is an equivalent of the C preprocessor for OCaml
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:05 GMT) Full text and rfc822 format available.

Message #29 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 08/10] gnu: ocaml-re: Use dune-build-system.
Date: Mon, 19 Nov 2018 23:28:19 +0100
* gnu/packages/ocaml.scm (ocaml-re): Use dune-build-system.
---
 gnu/packages/ocaml.scm | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index fe844b82d..5ba9a9ad6 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -3635,26 +3635,14 @@ standard iterator type starting from 4.07.")
               (sha256
                (base32
                 "1pdb0mr6z5ax6szblr3f5lbdnqq9grm97cmsfjmdma60yrx2rqhd"))))
-    (build-system ocaml-build-system)
+    (build-system dune-build-system)
     (arguments
      `(#:tests? #f
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'build
-           (lambda _
-             (invoke "dune" "build" "@install" "--profile" "release")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "dune" "install"
-                     "--prefix" (assoc-ref outputs "out"))
-             #t)))))
+       #:build-flags (list "--profile" "release")))
     (propagated-inputs
      `(("ocaml-seq" ,ocaml-seq)))
     (native-inputs
-     `(("dune" ,dune)
-       ("ounit" ,ocaml-ounit)))
+     `(("ounit" ,ocaml-ounit)))
     (home-page "https://github.com/ocaml/ocaml-re/")
     (synopsis "Regular expression library for OCaml")
     (description "Pure OCaml regular expressions with:
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:05 GMT) Full text and rfc822 format available.

Message #32 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 09/10] gnu: ocaml-camomile: Use dune-build-system.
Date: Mon, 19 Nov 2018 23:28:20 +0100
* gnu/packages/ocaml.scm (ocaml-camomile): Use dune-build-system.
---
 gnu/packages/ocaml.scm | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 5ba9a9ad6..896f3840a 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -4376,23 +4376,11 @@ the plugins facilitate extensibility, and the frontends serve as entry points.")
               (sha256
                (base32
                 "01ssjrqz41jvrqh27jxnh9cx7ywi9b5sgsykd00i7z9nrcwhlfy2"))))
-    (build-system ocaml-build-system)
+    (build-system dune-build-system)
     (native-inputs
-     `(("camlp4" ,camlp4)
-       ("dune" ,dune)))
+     `(("camlp4" ,camlp4)))
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'build
-           (lambda _
-             (invoke "dune" "build" "@install" "--profile" "release")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "dune" "install"
-                     "--prefix" (assoc-ref outputs "out"))
-             #t)))
+     `(#:build-flags (list "--profile" "realease")
        #:tests? #f))
     (synopsis "Comprehensive Unicode library")
     (description "Camomile is a Unicode library for OCaml.  Camomile provides
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Mon, 19 Nov 2018 22:29:06 GMT) Full text and rfc822 format available.

Message #35 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437 <at> debbugs.gnu.org
Subject: [PATCH 10/10] gnu: ocaml-lambda-term: Use dune-build-system.
Date: Mon, 19 Nov 2018 23:28:21 +0100
* gnu/packages/ocaml.scm (ocaml-lambda-term): Use dune-build-system.
---
 gnu/packages/ocaml.scm | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 896f3840a..7ed5c1951 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -4481,23 +4481,10 @@ connect an engine to your inputs and rendering functions to get an editor.")
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
         (base32 "1hy5ryagqclgdm9lzh1qil5mrynlypv7mn6qm858hdcnmz9zzn0l"))))
-    (build-system ocaml-build-system)
+    (build-system dune-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (replace 'build
-           (lambda _
-             (invoke "dune" "build" "@install" "--profile" "release")
-             #t))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "dune" "install"
-                     "--prefix" (assoc-ref outputs "out"))
-             #t)))
+     `(#:build-flags (list "--profile" "release")
        #:tests? #f))
-    (native-inputs
-     `(("dune" ,dune)))
     (propagated-inputs
      `(("lwt" ,ocaml-lwt)
        ("lwt-log" ,ocaml-lwt-log)
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Sat, 24 Nov 2018 21:18:01 GMT) Full text and rfc822 format available.

Message #38 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Julien Lepiller <julien <at> lepiller.eu>
Cc: 33437 <at> debbugs.gnu.org
Subject: Re: [bug#33437] [PATCH 01/10] build: Add dune-build-system.
Date: Sat, 24 Nov 2018 22:17:13 +0100
Hello Julien!

Julien Lepiller <julien <at> lepiller.eu> skribis:

> * guix/build/dune-build-system.scm,
>   guix/build-system/dune.scm: New files.
> * Makefile.am (MODULES): Add them.
> * doc/guix.texi (Build Systems): Document dune-build-system.
> * guix/build-system/ocaml.scm (lower, default-findlib, default-ocaml): Export
> them.
> (package-with-explicit-ocaml): Also transform packages built with
> dune-build-system.

Nice!

> +@defvr {Scheme Variable} dune-build-system
> +This variable is exported by @code{(guix build-system dune)}.  It
> +supports builds of packaes using Dune, a build tool for the
                           ^
Typo.

> +@uref{https://ocaml.org, OCaml programming language}.  It is implemented

Maybe add a link for Dune rather than for OCaml?


> +as an extension of the @code{ocaml-build-system} which is describe below.
                                                                    ^
Typo.

> +It automically adds the @code{dune} package to the set of inputs.
          ^^
“automatically”

> +The @code{'configure} phase is removed as dune packages typically

Maybe: “There is no @code{configure} phase because Dune packages…”?

> +The @code{#:legacy?} parameter can be passed to use the @code{jbuild}
> +command instead of the more recent @code{dune} command while building
> +a package.  Its default value is @code{#f}.

Should it be called #:jbuild? instead?  Because eventually everything
becomes “legacy”.  :-)

> +;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
> +(define-module (guix build-system dune)

Nitpick: please insert a newline before ‘define-module’.   :-)

> +(define* (dune-build store name inputs
> +                     #:key (guile #f)
> +                     (outputs '("out"))
> +                     (search-paths '())
> +                     (build-flags ''())
> +                     (out-of-source? #t)
> +                     (legacy? #f)
> +                     (tests? #t)
> +                     (test-flags ''())
> +                     (test-target "test")
> +                     (install-target "install")
> +                     (validate-runpath? #t)
> +                     (patch-shebangs? #t)
> +                     (strip-binaries? #t)
> +                     (strip-flags ''("--strip-debug"))
> +                     (strip-directories ''("lib" "lib64" "libexec"
> +                                           "bin" "sbin"))
> +                     (phases '(@ (guix build dune-build-system)
> +                                 %standard-phases))
> +                     (system (%current-system))
> +                     (imported-modules %dune-build-system-modules)
> +                     (modules '((guix build dune-build-system)
> +                                (guix build utils))))

Would it make sense to add (guix build ocaml-build-system) as well to
the default #:modules?

> +++ b/guix/build-system/ocaml.scm
> @@ -31,6 +31,9 @@
>              package-with-ocaml4.02
>              strip-ocaml4.01-variant
>              strip-ocaml4.02-variant
> +            default-findlib
> +            default-ocaml
> +            lower
>              ocaml-build
>              ocaml-build-system))
>  
> @@ -76,6 +79,13 @@
>    (let ((module (resolve-interface '(gnu packages ocaml))))
>      (module-ref module 'ocaml-findlib)))
>  
> +(define (default-dune-build-system)
> +  "Return the dune-build-system."
> +
> +  ;; Do not use `@' to avoid introducing circular dependencies.
> +  (let ((module (resolve-interface '(guix build-system dune))))
> +    (module-ref module 'dune-build-system)))
> +
>  (define (default-ocaml4.01)
>    (let ((ocaml (resolve-interface '(gnu packages ocaml))))
>      (module-ref ocaml 'ocaml-4.01)))
> @@ -119,7 +129,8 @@ pre-defined variants."
>        => force)
>  
>       ;; Otherwise build the new package object graph.
> -     ((eq? (package-build-system p) ocaml-build-system)
> +     ((or (eq? (package-build-system p) ocaml-build-system)
> +          (eq? (package-build-system p) (default-dune-build-system)))

I don’t have a better solution to offer here, but this whole
‘package-with-explicit-XYZ’ is clearly showing its limits here.  :-/

Otherwise LGTM, thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#33437; Package guix-patches. (Sat, 24 Nov 2018 21:19:02 GMT) Full text and rfc822 format available.

Message #41 received at 33437 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Julien Lepiller <julien <at> lepiller.eu>
Cc: 33437 <at> debbugs.gnu.org
Subject: Re: [bug#33437] [PATCH 10/10] gnu: ocaml-lambda-term: Use
 dune-build-system.
Date: Sat, 24 Nov 2018 22:18:27 +0100
The remaining patches LGTM.  Perhaps it would be best to commit all this
to ‘core-updates’, to avoid gratuitous rebuilds of all the OCaml
packages now that we’re close to merging ‘core-updates’.

Thank you!

Ludo’.




Reply sent to Julien Lepiller <julien <at> lepiller.eu>:
You have taken responsibility. (Tue, 18 Dec 2018 21:42:02 GMT) Full text and rfc822 format available.

Notification sent to Julien Lepiller <julien <at> lepiller.eu>:
bug acknowledged by developer. (Tue, 18 Dec 2018 21:42:02 GMT) Full text and rfc822 format available.

Message #46 received at 33437-done <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: 33437-done <at> debbugs.gnu.org
Subject: Re: [bug#33437] [PATCH] Add dune-build-system
Date: Tue, 18 Dec 2018 22:41:47 +0100
Le Mon, 19 Nov 2018 23:25:37 +0100,
Julien Lepiller <julien <at> lepiller.eu> a écrit :

> Hi, here is a small patch series to add dune-build-system and convert
> a few packages to it.

pushed as 6e8986c8388e889eb74509999aea826fd440dcc4 -
34d5314e9c826b1f602f9aaa8d707ca594736aaf




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 16 Jan 2019 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 95 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.