[bug#75325,rust-team,2/2] build-system: cargo: add-dependencies: Silence warning.
Commit Message
* 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(-)
@@ -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"))