unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#75325] [PATCH rust-team 0/2] Add add-dependencies procedure.
@ 2025-01-03 19:38 Herman Rimm via Guix-patches via
  2025-01-03 19:40 ` [bug#75325] [PATCH rust-team 1/2] build-system: cargo: " Herman Rimm via Guix-patches via
  2025-01-03 19:40 ` [bug#75325] [PATCH rust-team 2/2] build-system: cargo: add-dependencies: Silence warning Herman Rimm via Guix-patches via
  0 siblings, 2 replies; 3+ messages in thread
From: Herman Rimm via Guix-patches via @ 2025-01-03 19:38 UTC (permalink / raw)
  To: 75325; +Cc: Efraim Flashner

Hello,

(parameterize ((current-warning-port (%make-void-port "w"))) ...) does
not silence the warning emitted by the format.

Cheers,
Herman

Herman Rimm (2):
  build-system: cargo: Add add-dependencies procedure.
  build-system: cargo: add-dependencies: Silence warning.

 guix/build-system/cargo.scm | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)


base-commit: 5f92f009a19c1a5a8b7df5a7bcb1e1f283a953f8
-- 
2.45.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [bug#75325] [PATCH rust-team 1/2] build-system: cargo: Add add-dependencies procedure.
  2025-01-03 19:38 [bug#75325] [PATCH rust-team 0/2] Add add-dependencies procedure Herman Rimm via Guix-patches via
@ 2025-01-03 19:40 ` Herman Rimm via Guix-patches via
  2025-01-03 19:40 ` [bug#75325] [PATCH rust-team 2/2] build-system: cargo: add-dependencies: Silence warning Herman Rimm via Guix-patches via
  1 sibling, 0 replies; 3+ messages in thread
From: Herman Rimm via Guix-patches via @ 2025-01-03 19:40 UTC (permalink / raw)
  To: 75325; +Cc: Efraim Flashner

* guix/build-system/cargo.scm (add-dependencies): Add procedure.

Change-Id: I5385d136697bb6d41a5bd4f6120150f841369a04
---
 guix/build-system/cargo.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 452f7f78d01..b22b9247a1c 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -6,7 +6,7 @@
 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2021, 2024 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
+;;; Copyright © 2024-2025 Herman Rimm <herman@rimm.ee>
 ;;; Copyright © 2024 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -38,7 +38,8 @@ (define-module (guix build-system cargo)
   #:use-module (ice-9 vlist)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
-  #:export (%cargo-build-system-modules
+  #:export (add-dependencies
+            %cargo-build-system-modules
             %cargo-utils-modules
             cargo-build-system
             %crate-base-url
@@ -46,6 +47,18 @@ (define-module (guix build-system cargo)
             crate-url?
             crate-uri))
 
+;; TODO: Move to (guix build cargo-utils).
+(define* (add-dependencies dependencies)
+  "DEPENDENCIES is a list of (crate version features).  It is formatted
+and appendended to Cargo.toml."
+  #~(let ((port (open-file "Cargo.toml" "a")))
+      (format port "
+~:{[dev-dependencies.~a]
+version = ~s
+~@[features = [~{~s~^,~}]~]~%~}"
+              '#$dependencies)
+      (close port)))
+
 (define %crate-base-url
   (make-parameter "https://crates.io"))
 (define crate-url
-- 
2.45.2





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#75325] [PATCH rust-team 2/2] build-system: cargo: add-dependencies: Silence warning.
  2025-01-03 19:38 [bug#75325] [PATCH rust-team 0/2] Add add-dependencies procedure Herman Rimm via Guix-patches via
  2025-01-03 19:40 ` [bug#75325] [PATCH rust-team 1/2] build-system: cargo: " Herman Rimm via Guix-patches via
@ 2025-01-03 19:40 ` Herman Rimm via Guix-patches via
  1 sibling, 0 replies; 3+ messages in thread
From: Herman Rimm via Guix-patches via @ 2025-01-03 19:40 UTC (permalink / raw)
  To: 75325; +Cc: Efraim Flashner

* guix/build-system/cargo.scm (add-dependencies): Silence warning.

Change-Id: I8691766fc19073719e75c05eb5bfbce45ffc9b80
---
 guix/build-system/cargo.scm | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index b22b9247a1c..877ebaec135 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -34,6 +34,7 @@ (define-module (guix build-system cargo)
   #:use-module (guix platform)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:use-module (ice-9 vlist)
   #:use-module (srfi srfi-1)
@@ -51,13 +52,20 @@ (define-module (guix build-system cargo)
 (define* (add-dependencies dependencies)
   "DEPENDENCIES is a list of (crate version features).  It is formatted
 and appendended to Cargo.toml."
-  #~(let ((port (open-file "Cargo.toml" "a")))
-      (format port "
+  (let ((dependencies
+         (map (match-lambda
+                ((crate version ()) (list crate version #f))
+                ((crate version (? pair? features))
+                 (list crate version (format #f "~{~s~^,~}" features)))
+                (dep dep))
+              dependencies)))
+    #~(let ((port (open-file "Cargo.toml" "a")))
+        (format port "
 ~:{[dev-dependencies.~a]
 version = ~s
-~@[features = [~{~s~^,~}]~]~%~}"
-              '#$dependencies)
-      (close port)))
+~@[features = [~a]~]~%~}"
+                '#$dependencies)
+        (close port))))
 
 (define %crate-base-url
   (make-parameter "https://crates.io"))
-- 
2.45.2





^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-03 19:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-03 19:38 [bug#75325] [PATCH rust-team 0/2] Add add-dependencies procedure Herman Rimm via Guix-patches via
2025-01-03 19:40 ` [bug#75325] [PATCH rust-team 1/2] build-system: cargo: " Herman Rimm via Guix-patches via
2025-01-03 19:40 ` [bug#75325] [PATCH rust-team 2/2] build-system: cargo: add-dependencies: Silence warning Herman Rimm via Guix-patches via

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).