unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Julien Lepiller <julien@lepiller.eu>
To: 35150@debbugs.gnu.org
Subject: [bug#35150] [PATCH 2/9] import: opam: Use dune-build-system when possible.
Date: Thu,  4 Apr 2019 21:16:31 +0200	[thread overview]
Message-ID: <20190404191638.31953-2-julien@lepiller.eu> (raw)
In-Reply-To: <20190404191638.31953-1-julien@lepiller.eu>

* guix/import/opam.scm (opam->guix-package): Detect when dune can be used.
---
 guix/import/opam.scm | 80 ++++++++++++++++++++++++++------------------
 1 file changed, 48 insertions(+), 32 deletions(-)

diff --git a/guix/import/opam.scm b/guix/import/opam.scm
index b5069cd2f3..5dcc0e97a3 100644
--- a/guix/import/opam.scm
+++ b/guix/import/opam.scm
@@ -247,39 +247,55 @@ path to the repository."
              (url-dict (metadata-ref opam-content "url"))
              (source-url (metadata-ref url-dict "src"))
              (requirements (metadata-ref opam-content "depends"))
-             (dependencies (dependency-list->names requirements))
+             (dependencies (filter
+                              (lambda (name)
+                                (not (member name '("dune" "jbuilder"))))
+                              (dependency-list->names requirements)))
+             (native-dependencies (depends->native-inputs requirements))
              (inputs (dependency-list->inputs (depends->inputs requirements)))
-             (native-inputs (dependency-list->inputs (depends->native-inputs requirements))))
-        (call-with-temporary-output-file
-          (lambda (temp port)
-            (and (url-fetch source-url temp)
-                 (values
-                  `(package
-                     (name ,(ocaml-name->guix-name name))
-                     (version ,(if (string-prefix? "v" version)
-                                 (substring version 1)
-                                 version))
-                     (source
-                       (origin
-                         (method url-fetch)
-                         (uri ,source-url)
-                         (sha256 (base32 ,(guix-hash-url temp)))))
-                     (build-system ocaml-build-system)
-                     ,@(if (null? inputs)
-                         '()
-                         `((inputs ,(list 'quasiquote inputs))))
-                     ,@(if (null? native-inputs)
-                         '()
-                         `((native-inputs ,(list 'quasiquote native-inputs))))
-                     ,@(if (equal? name (guix-name->opam-name (ocaml-name->guix-name name)))
-                         '()
-                         `((properties
-                             ,(list 'quasiquote `((upstream-name . ,name))))))
-                     (home-page ,(metadata-ref opam-content "homepage"))
-                     (synopsis ,(metadata-ref opam-content "synopsis"))
-                     (description ,(metadata-ref opam-content "description"))
-                     (license #f))
-                  dependencies))))))
+             (native-inputs (dependency-list->inputs
+                              ;; Do not add dune nor jbuilder since they are
+                              ;; implicit inputs of the dune-build-system.
+                              (filter
+                                (lambda (name)
+                                  (not (member name '("dune" "jbuilder"))))
+                                native-dependencies))))
+        ;; If one of these are required at build time, it means we
+        ;; can use the much nicer dune-build-system.
+        (let ((use-dune? (or (member "dune" native-dependencies)
+                        (member "jbuilder" native-dependencies))))
+          (call-with-temporary-output-file
+            (lambda (temp port)
+              (and (url-fetch source-url temp)
+                   (values
+                    `(package
+                       (name ,(ocaml-name->guix-name name))
+                       (version ,(if (string-prefix? "v" version)
+                                   (substring version 1)
+                                   version))
+                       (source
+                         (origin
+                           (method url-fetch)
+                           (uri ,source-url)
+                           (sha256 (base32 ,(guix-hash-url temp)))))
+                       (build-system ,(if use-dune?
+                                          'dune-build-system
+                                          'ocaml-build-system))
+                       ,@(if (null? inputs)
+                           '()
+                           `((inputs ,(list 'quasiquote inputs))))
+                       ,@(if (null? native-inputs)
+                           '()
+                           `((native-inputs ,(list 'quasiquote native-inputs))))
+                       ,@(if (equal? name (guix-name->opam-name (ocaml-name->guix-name name)))
+                           '()
+                           `((properties
+                               ,(list 'quasiquote `((upstream-name . ,name))))))
+                       (home-page ,(metadata-ref opam-content "homepage"))
+                       (synopsis ,(metadata-ref opam-content "synopsis"))
+                       (description ,(metadata-ref opam-content "description"))
+                       (license #f))
+                    dependencies)))))))
 
 (define (opam-recursive-import package-name)
   (recursive-import package-name #f
-- 
2.21.0

  reply	other threads:[~2019-04-04 19:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 18:54 [bug#35150] [PATCH] Unbundle opam dependencies Julien Lepiller
2019-04-04 19:16 ` [bug#35150] [PATCH 1/9] import: opam: Add more patterns to opam file parser Julien Lepiller
2019-04-04 19:16   ` Julien Lepiller [this message]
2019-04-04 19:16   ` [bug#35150] [PATCH 3/9] gnu: Add ocaml-opam-file-format Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 4/9] gnu: ocaml-cmdliner: Update to 1.0.3 Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 5/9] gnu: Add ocaml-extlib Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 6/9] gnu: Add ocaml-cudf Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 7/9] gnu: Add ocaml-mccs Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 8/9] gnu: Add ocaml-dose3 Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 9/9] gnu: opam: Unbundle dependencies Julien Lepiller
2019-04-10 15:08   ` [bug#35150] [PATCH 1/9] import: opam: Add more patterns to opam file parser Ludovic Courtès
2019-04-10 15:09 ` [bug#35150] [PATCH] Unbundle opam dependencies Ludovic Courtès
2019-04-10 19:48   ` bug#35150: " Julien Lepiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190404191638.31953-2-julien@lepiller.eu \
    --to=julien@lepiller.eu \
    --cc=35150@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).