guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

390/436: gnu: rust: Allow using custom rust-src for rust-analyzer.


From: guix-commits
Subject: 390/436: gnu: rust: Allow using custom rust-src for rust-analyzer.
Date: Sun, 5 Nov 2023 05:29:59 -0500 (EST)

efraim pushed a commit to branch rust-team
in repository guix.

commit 9c227b7c67e43b74d5facdf23602ddf6dd18d448
Author: Efraim Flashner <efraim@flashner.co.il>
AuthorDate: Sun Nov 5 08:55:31 2023 +0200

    gnu: rust: Allow using custom rust-src for rust-analyzer.
    
    * gnu/packages/rust.scm (rust)[arguments]: Rewrite 'wrap-rust-analyzer
    phase to allow using a custom RUST_SRC_PATH.
    
    Change-Id: Id811bc8d09c0f955ece9c9e6267a0ae96e61f105
---
 gnu/packages/rust.scm | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 87bd578e9e..e11148e89e 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1030,11 +1030,19 @@ safety and thread safety guarantees.")
                    (copy-recursively "src" (string-append out dest "/src")))))
              (add-after 'install-rust-src 'wrap-rust-analyzer
                (lambda* (#:key outputs #:allow-other-keys)
-                 (wrap-program (string-append (assoc-ref outputs "tools")
-                                              "/bin/rust-analyzer")
-                   `("RUST_SRC_PATH" ":" =
-                     (,(string-append (assoc-ref outputs "rust-src")
-                                      "/lib/rustlib/src/rust/library"))))))))))
+                 (let ((bin (string-append (assoc-ref outputs "tools") 
"/bin")))
+                   (rename-file (string-append bin "/rust-analyzer")
+                                (string-append bin "/.rust-analyzer-real"))
+                   (call-with-output-file (string-append bin "/rust-analyzer")
+                     (lambda (port)
+                       (format port "#!~a
+if test -z \"${RUST_SRC_PATH}\";then export RUST_SRC_PATH=~S;fi;
+exec -a \"$0\" \"~a\" \"$@\""
+                               (which "bash")
+                               (string-append (assoc-ref outputs "rust-src")
+                                              "/lib/rustlib/src/rust/library")
+                               (string-append bin "/.rust-analyzer-real"))))
+                   (chmod (string-append bin "/rust-analyzer") #o755))))))))
       ;; Add test inputs.
       (native-inputs (cons* `("gdb" ,gdb/pinned)
                             `("procps" ,procps)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]