Subject: [bug#69620] [PATCH rust-team v4 5/5] gnu: rust-rocket and rust-pear: Enable building

From: Aaron Covrig <[email-masked]>
Date: Fri, 4 Oct 2024 14:27:54 -0400

* gnu/packages/crates-io.scm (rust-pear-0.1): Enable building and tests
* gnu/packages/crates-io.scm (rust-pear-codegen-0.1): Enable building
  and tests
* gnu/packages/crates-web.scm (rust-rocket-0.4): Enable building and
  tests
* gnu/packages/crates-web.scm (rust-rocket-codegen-0.4): Enable building
  and tests
* gnu/packages/crates-web.scm (rust-rocket-http-0.4): Enable building
  and tests
---
 gnu/packages/crates-io.scm  |  35 +++++++---
 gnu/packages/crates-web.scm | 126 +++++++++++++++++++++++-------------
 2 files changed, 107 insertions(+), 54 deletions(-)

diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index dd26496ece..647efce272 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -53088,8 +53088,13 @@ (define-public rust-pear-0.1
        (sha256
         (base32 "02lnp8c414z5ds0lskd4zxlalrjljzpkg8g6kizszij4h52sgprj"))))
     (arguments
-     `(#:skip-build? #t
-       #:cargo-inputs (("rust-pear-codegen" ,rust-pear-codegen-0.1))))))
+     (list
+      #:cargo-inputs `(("rust-pear-codegen" ,rust-pear-codegen-0.1))
+      #:phases #~(modify-phases %standard-phases
+                   ;; Enable using nightly/dev features
+                   (add-after 'unpack 'enable-unstable-features
+                     (lambda _
+                       (setenv "RUSTC_BOOTSTRAP" "1"))))))))
 
 (define-public rust-pear-codegen-0.2
   (package
@@ -53134,15 +53139,25 @@ (define-public rust-pear-codegen-0.1
        (uri (crate-uri "pear_codegen" version))
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
-        (base32 "19lcpkfspizd4ywwvca6rxgc311m070k3ndvwa9vrbw1snjqna60"))))
+        (base32 "19lcpkfspizd4ywwvca6rxgc311m070k3ndvwa9vrbw1snjqna60"))
+       (modules '((guix build utils)))
+       (snippet '(begin
+                   (delete-file "build.rs")))))
     (arguments
-     `(#:skip-build? #t
-       #:cargo-inputs
-       (("rust-proc-macro2" ,rust-proc-macro2-0.4)
-        ("rust-quote" ,rust-quote-0.6)
-        ("rust-syn" ,rust-syn-0.15)
-        ("rust-version-check" ,rust-version-check-0.9)
-        ("rust-yansi" ,rust-yansi-0.5))))))
+     (list
+      #:cargo-inputs `(("rust-proc-macro2" ,rust-proc-macro2-0.4)
+                       ("rust-quote" ,rust-quote-0.6)
+                       ("rust-syn" ,rust-syn-0.15)
+                       ;; development inputs here to address build issues
+                       ("rust-version-check" ,rust-version-check-0.9)
+                       ("rust-yansi" ,rust-yansi-0.5))
+      #:cargo-development-inputs `(("rust-version-check" ,rust-version-check-0.9)
+                                   ("rust-yansi" ,rust-yansi-0.5))
+      #:phases #~(modify-phases %standard-phases
+                   ;; Enable using nightly/dev features
+                   (add-after 'unpack 'enable-unstable-features
+                     (lambda _
+                       (setenv "RUSTC_BOOTSTRAP" "1"))))))))
 
 (define-public rust-peeking-take-while-0.1
   (package
diff --git a/gnu/packages/crates-web.scm b/gnu/packages/crates-web.scm
index 70158c7f60..0c9260ead5 100644
--- a/gnu/packages/crates-web.scm
+++ b/gnu/packages/crates-web.scm
@@ -4920,31 +4920,50 @@ (define-public rust-rocket-0.4
   (package
     (inherit rust-rocket-0.5)
     (name "rust-rocket")
-    (version "0.4.7")
+    (version "0.4.11")
     (source
      (origin
        (method url-fetch)
        (uri (crate-uri "rocket" version))
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
-        (base32 "04ybnhjw92zaan92lsmx6mkhqc9cpsg3885svb3wzyj39pyzvsvz"))))
+        (base32 "0pimz9v0737dvz487j0kij7kasjyahaxd7ba2bcc3p6513fdkfc3"))
+       (modules '((guix build utils)))
+       (snippet '(begin
+                   ;; enable nightly/dev in build.rs for RUSTC_BOOTSTRAP build
+                   (substitute* "build.rs"
+                     (("if !channel.supports_features")
+                      "/* if !channel.supports_features")
+                     (("if !version.at_least")
+                      "*/ \nif !version.at_least"))
+                   ;; Add missing development dependency (for tests)
+                   (substitute* "Cargo.toml"
+                     (("\\[features\\]" all)
+                      (string-append "[dev-dependencies.lazy_static]" "\n"
+                                     "version = \"1\"" "\n" all))) #t))))
     (arguments
-     `(#:skip-build? #t
-       #:cargo-inputs
-       (("rust-atty" ,rust-atty-0.2)
-        ("rust-base64" ,rust-base64-0.12)
-        ("rust-log" ,rust-log-0.4)
-        ("rust-memchr" ,rust-memchr-2)
-        ("rust-num-cpus" ,rust-num-cpus-1)
-        ("rust-pear" ,rust-pear-0.1)
-        ("rust-rocket-codegen" ,rust-rocket-codegen-0.4)
-        ("rust-rocket-http" ,rust-rocket-http-0.4)
-        ("rust-state" ,rust-state-0.4)
-        ("rust-time" ,rust-time-0.1)
-        ("rust-toml" ,rust-toml-0.4)
-        ("rust-version-check" ,rust-version-check-0.9)
-        ("rust-yansi" ,rust-yansi-0.5)
-        ("rust-yansi" ,rust-yansi-0.5))))))
+     (list
+      #:cargo-inputs `(("rust-atty" ,rust-atty-0.2)
+                       ("rust-base64" ,rust-base64-0.12)
+                       ("rust-log" ,rust-log-0.4)
+                       ("rust-memchr" ,rust-memchr-2)
+                       ("rust-num-cpus" ,rust-num-cpus-1)
+                       ("rust-pear" ,rust-pear-0.1)
+                       ("rust-rocket-codegen" ,rust-rocket-codegen-0.4)
+                       ("rust-rocket-http" ,rust-rocket-http-0.4)
+                       ("rust-state" ,rust-state-0.4)
+                       ("rust-time" ,rust-time-0.1)
+                       ("rust-toml" ,rust-toml-0.4)
+                       ("rust-version-check" ,rust-version-check-0.9)
+                       ("rust-yansi" ,rust-yansi-0.5)
+                       ("rust-yansi" ,rust-yansi-0.5))
+      ;; Adding in missing dev dependency
+      #:cargo-development-inputs `(("rust-lazy-static" ,rust-lazy-static-1))
+      #:phases #~(modify-phases %standard-phases
+                   ;; Enable using nightly/dev features
+                   (add-after 'unpack 'enable-unstable-features
+                     (lambda _
+                       (setenv "RUSTC_BOOTSTRAP" "1"))))))))
 
 (define-public rust-rocket-codegen-0.5
   (package
@@ -4984,24 +5003,38 @@ (define-public rust-rocket-codegen-0.4
   (package
     (inherit rust-rocket-codegen-0.5)
     (name "rust-rocket-codegen")
-    (version "0.4.7")
+    (version "0.4.11")
     (source
      (origin
        (method url-fetch)
        (uri (crate-uri "rocket_codegen" version))
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
-        (base32 "18s2dll8c4sd26s8cfr6cizj5z55xwnk6r6x7b2wvcf8n9ajrb6f"))))
+        (base32 "1zl4f99s4df8fpkps53qn77030baww4x7zflggwql290b1xh6418"))
+       (modules '((guix build utils)))
+       (snippet '(begin
+                   (substitute* "build.rs"
+                     ;; enable nightly/dev in build.rs for RUSTC_BOOTSTRAP build
+                     (("if !channel.supports_features")
+                      "/* if !channel.supports_features")
+                     (("if !version.at_least")
+                      "*/ \nif !version.at_least"))))))
     (arguments
-     `(#:skip-build? #t
-       #:cargo-inputs
-       (("rust-devise" ,rust-devise-0.2)
-        ("rust-glob" ,rust-glob-0.3)
-        ("rust-indexmap" ,rust-indexmap-1)
-        ("rust-quote" ,rust-quote-0.6)
-        ("rust-rocket-http" ,rust-rocket-http-0.4)
-        ("rust-version-check" ,rust-version-check-0.9)
-        ("rust-yansi" ,rust-yansi-0.5))))))
+     (list
+      #:tests? #f ;Tests depend on multiple undeclared crates
+      #:cargo-inputs `(("rust-devise" ,rust-devise-0.2)
+                       ("rust-glob" ,rust-glob-0.3)
+                       ("rust-indexmap" ,rust-indexmap-1)
+                       ("rust-quote" ,rust-quote-0.6)
+                       ("rust-rocket-http" ,rust-rocket-http-0.4))
+      #:cargo-development-inputs `(("rust-version-check" ,rust-version-check-0.9)
+                                   ("rust-yansi" ,rust-yansi-0.5)
+                                   ("rust-rocket" ,rust-rocket-0.4)) ;For tests
+      #:phases #~(modify-phases %standard-phases
+                   ;; Enable using nightly/dev features
+                   (add-after 'unpack 'enable-unstable-features
+                     (lambda _
+                       (setenv "RUSTC_BOOTSTRAP" "1"))))))))
 
 (define-public rust-rocket-http-0.5
   (package
@@ -5053,28 +5086,33 @@ (define-public rust-rocket-http-0.4
   (package
     (inherit rust-rocket-http-0.5)
     (name "rust-rocket-http")
-    (version "0.4.7")
+    (version "0.4.11")
     (source
      (origin
        (method url-fetch)
        (uri (crate-uri "rocket_http" version))
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
-        (base32 "0ga98nbcga8amg4xhrfkn1wljnqx9h0vv7mnay9g66vsxl042dnf"))))
+        (base32 "17xiivj4cp3anm4rxxpd8g58kzday1y2pgdys2i23wz1538wpy9b"))))
     (arguments
-     `(#:skip-build? #t
-       #:cargo-inputs
-       (("rust-cookie" ,rust-cookie-0.11)
-        ("rust-hyper" ,rust-hyper-0.10)
-        ("rust-hyper-sync-rustls" ,rust-hyper-sync-rustls-0.3)
-        ("rust-indexmap" ,rust-indexmap-1)
-        ("rust-pear" ,rust-pear-0.1)
-        ("rust-percent-encoding" ,rust-percent-encoding-1)
-        ("rust-rustls" ,rust-rustls-0.14)
-        ("rust-smallvec" ,rust-smallvec-1)
-        ("rust-state" ,rust-state-0.4)
-        ("rust-time" ,rust-time-0.1)
-        ("rust-unicode-xid" ,rust-unicode-xid-0.1))))))
+     `(#:cargo-test-flags ;doctests depend on undeclared crates
+       '("--lib" "--bins" "--tests" "--release")
+       #:cargo-inputs (("rust-cookie" ,rust-cookie-0.11)
+                       ("rust-hyper" ,rust-hyper-0.10)
+                       ("rust-hyper-sync-rustls" ,rust-hyper-sync-rustls-0.3)
+                       ("rust-indexmap" ,rust-indexmap-1)
+                       ("rust-pear" ,rust-pear-0.1)
+                       ("rust-percent-encoding" ,rust-percent-encoding-1)
+                       ("rust-rustls" ,rust-rustls-0.14)
+                       ("rust-smallvec" ,rust-smallvec-1)
+                       ("rust-state" ,rust-state-0.4)
+                       ("rust-time" ,rust-time-0.1)
+                       ("rust-unicode-xid" ,rust-unicode-xid-0.1))
+       #:phases (modify-phases %standard-phases
+                  ;; Enable using nightly/dev features
+                  (add-after 'unpack 'enable-unstable-features
+                    (lambda _
+                      (setenv "RUSTC_BOOTSTRAP" "1"))))))))
 
 (define-public rust-salvo-0.16
   (package
-- 
2.46.0