From patchwork Sat Jan 22 04:37:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Z572 <873216071@qq.com> X-Patchwork-Id: 36736 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 40DE927BBEA; Sat, 22 Jan 2022 05:13:29 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,FREEMAIL_REPLYTO_END_DIGIT, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8D90A27BBE9 for ; Sat, 22 Jan 2022 05:13:28 +0000 (GMT) Received: from localhost ([::1]:44562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nB8iN-0001dL-Pj for patchwork@mira.cbaines.net; Sat, 22 Jan 2022 00:13:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nB8iE-0001cx-B9 for guix-patches@gnu.org; Sat, 22 Jan 2022 00:13:18 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:42625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nB8hx-0000V7-RN for guix-patches@gnu.org; Sat, 22 Jan 2022 00:13:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nB8hx-0003CN-Mf for guix-patches@gnu.org; Sat, 22 Jan 2022 00:13:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53208] [PATCH 39/39] gnu: rust-analyzer: Make it out of box. Resent-From: Z572 <873216071@qq.com> Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 22 Jan 2022 05:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53208 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Nicolas Goaziou Cc: 53208@debbugs.gnu.org Received: via spool by 53208-submit@debbugs.gnu.org id=B53208.164282837612281 (code B ref 53208); Sat, 22 Jan 2022 05:13:01 +0000 Received: (at 53208) by debbugs.gnu.org; 22 Jan 2022 05:12:56 +0000 Received: from localhost ([127.0.0.1]:35528 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nB8hn-0003Bx-5i for submit@debbugs.gnu.org; Sat, 22 Jan 2022 00:12:56 -0500 Received: from out162-62-57-64.mail.qq.com ([162.62.57.64]:41043) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <873216071@qq.com>) id 1nB8hh-0003BY-IG for 53208@debbugs.gnu.org; Sat, 22 Jan 2022 00:12:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1642828355; bh=BHnCOZDmEH1YrolIW7nx04borUDoiouFGhUcGXPvuek=; h=References:From:To:Cc:Subject:Date:In-reply-to; b=PHArzPFcqYHnYFwuPKV1cqpfJHjGcwPf7ry7nsXhNVCFyDYJywhsr+LR7gDrjDovT 6Cx4yNeEFEZOaBRxoTBWISGA1pvEmgIcGvFMWUq7S35oUQ4UBdnmPFU1C18afmQ/rS K7gEduuhLv8weIcHW1st5IvbU+14Gvazw67req5A= Received: from asus ([39.183.1.114]) by newxmesmtplogicsvrszc10.qq.com (NewEsmtp) with SMTP id 32228611; Sat, 22 Jan 2022 13:12:34 +0800 X-QQ-mid: xmsmtpt1642828354t6okgu24r Message-ID: X-QQ-XMAILINFO: Nqlrvrrau4mSCcL8OrXiIA9RBh4oAbsCmxP/AfTHrzY4BzATixBIetZjbFQUmg Vw6bN1FYCM2Fx6O2q5uDUqzlrZIDKeiGHqaY0wQNNaIWjk9XXVtoBVix5rxNKplIsFjOyWnqob2J gjl1iS9ehuJZLv1KQLjze0++p+1diReWhBFIQygUMB2XvBlEqw9iI4u0Y4N287gzWptheh8JZT0/ 7/SIgtlfaRigFTIiReejW9KVaWqq6cStgoYfZYFK56PxLsLLVMifOoUasqILkMW6+Jdxvu+ymG78 sJ1tzIZPvKgd0GssKEwgwxiH1YYsG+c3hxMetU6RapXb/59DxpjJB3Sf6WwdsjrTWm1N/rioaGCo qe78mH5hnGlM91X0DR/BLLAnV63Ys7VrgUWCx+xAO6vSYZs2DBUDde03777DQIWQ3Ztmu6xOOnfF fYhTQs3sWldO1Qk8GfftQ5k79tor8GzcexGD0dB0mMJvrx80e1gyoLMVqpxnkC6q8Qko1n6te8Ri g+Hs37xnRkDMfU5EsvtMDzdl1fZzOV9tmONyuZ3aOoLqdgAiRLYInZ5sSPOFYJQwE3j8Y5Hj0LBH bSYlAZAcAjfYUrbG9YcFD3d/Rdsurmk5pNoZ7NUBnRqyBLjsq9I7K0reoNeu+LmuebdWh+bq0gTC WRKe55tt8X+amWXjQoBhUyZsUOKZNgszuf+9sc9v6VQX9lBg/VJlC7IGv3mly4pF3VZ1AdzjuFLU MFZV9GIcPlYJunKWxKpkQvH8cBoG8xWJr2gIwj+ZU+ZRq/4D3xbvUAm6XeurQZ82yv+Xbg7cMdSD hLj9sIK8le+AEjhcGCenv35BBSqGr4Ld8= References: <87r1928016.fsf@nicolasgoaziou.fr> User-agent: mu4e 1.6.10; emacs 29.0.50 Date: Sat, 22 Jan 2022 12:37:10 +0800 In-reply-to: <87r1928016.fsf@nicolasgoaziou.fr> Message-ID: <87ee504am6.fsf@qq.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Z572 <873216071@qq.com> X-ACL-Warn: , Z572 via Guix-patches X-Patchwork-Original-From: Z572 via Guix-patches via From: Z572 <873216071@qq.com> X-getmail-retrieved-from-mailbox: Patches looks like failed to send email yesterday Nicolas Goaziou writes: > Hello, > > Z572 via Guix-patches via writes: > >> +(define-public rust-src >> + (hidden-package >> + (package >> + (inherit rust-1.57) >> + (name "rust-src") >> + (build-system copy-build-system) >> + (native-inputs '()) >> + (inputs '()) >> + (native-search-paths '()) >> + (outputs '("out")) >> + (arguments >> + `(#:install-plan >> + '(("library" "lib/rustlib/src/rust/library") >> + ("src" "lib/rustlib/src/rust/src")))) >> + (synopsis "Source code for the Rust standard library") >> + (description "This package provide source code for the Rust >> standard >> +library, only use by rust-analyzer, make rust-analyzer out of >> box.")))) > > This cannot work, because, AFAIK, you can only inherit packages from the > same module. So rust-src should be moved to rust.scm and made visible. It can work, for example: fdik-libetpan and libetpan. fdik-libetpan is in (gnu packages pep), libetpan is in (gnu packages mail), fdik-libetpan inherit from libetpan, them are in different module. > >> + (add-after 'install 'wrap-program >> + (lambda* (#:key inputs outputs #:allow-other-keys) >> + (let* ((out (assoc-ref outputs "out")) >> + (bin (string-append out "/bin")) >> + (rust-src-path (search-input-directory >> + inputs "/lib/rustlib/src/rust/library"))) >> + ;; if not get environment variable RUST_SRC_PATH, set it, >> + ;; make rust-analyzer out of box. >> + (with-directory-excursion bin >> + (let* ((prog "rust-analyzer") >> + (wrapped-file (string-append (dirname prog) >> + "/." (basename prog) "-real")) >> + (prog-tmp (string-append wrapped-file "-tmp"))) >> + (link prog wrapped-file) >> + (call-with-output-file prog-tmp >> + (lambda (port) >> + (format port "#!~a >> +if test -z \"${RUST_SRC_PATH}\";then export RUST_SRC_PATH=~S;fi; >> +exec -a \"$0\" \"~a\" \"$@\"" >> + (which "bash") >> + rust-src-path >> + (canonicalize-path wrapped-file)))) >> + (chmod prog-tmp #o755) >> + (rename-file prog-tmp prog)))))) > > I tried to move the rust-src in rust.scm, as explained above, but when > I do, installation of rust-analyzer fails during the `wrap-program' > phases. new patch move rust-src to rust.scm, and build rust-analyzer success. > >> (replace 'install-license-files >> (lambda* (#:key outputs #:allow-other-keys) >> (let* ((out (assoc-ref outputs "out")) >> @@ -1298,6 +1341,7 @@ (define-public rust-analyzer >> (chdir "../..") >> (install-file "LICENSE-MIT" doc) >> (install-file "LICENSE-APACHE" doc))))))) >> + (inputs (list rust-src)) > > Shouldn't it be a native-input? Fix in new patch. > > Could you have a look at those issues? Thanks! > > Regards, From a3ea65ba89f7f369fd6d2f8bd557dd59645ed456 Mon Sep 17 00:00:00 2001 Message-Id: From: Z572 <873216071@qq.com> Date: Fri, 21 Jan 2022 19:06:10 +0800 Subject: [PATCH] gnu: rust-analyzer: Make it out of the box. * gnu/packages/rust.scm (rust-src): New variable. * gnu/packages/rust-apps.scm (rust-analyzer): [native-inputs]: Add rust-src. [arguments]: <#:phases>: Add wrap-program phase. --- gnu/packages/rust-apps.scm | 25 +++++++++++++++++++++++++ gnu/packages/rust.scm | 20 ++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm index a31fabac36..8ffa3a9817 100644 --- a/gnu/packages/rust-apps.scm +++ b/gnu/packages/rust-apps.scm @@ -1408,6 +1408,30 @@ (define-public rust-analyzer (add-before 'install 'chdir (lambda _ (chdir "crates/rust-analyzer"))) + (add-after 'install 'wrap-program + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (rust-src-path (search-input-directory + inputs "/lib/rustlib/src/rust/library"))) + ;; if not get environment variable RUST_SRC_PATH, set it, + ;; make rust-analyzer out of box. + (with-directory-excursion bin + (let* ((prog "rust-analyzer") + (wrapped-file (string-append (dirname prog) + "/." (basename prog) "-real")) + (prog-tmp (string-append wrapped-file "-tmp"))) + (link prog wrapped-file) + (call-with-output-file prog-tmp + (lambda (port) + (format port "#!~a +if test -z \"${RUST_SRC_PATH}\";then export RUST_SRC_PATH=~S;fi; +exec -a \"$0\" \"~a\" \"$@\"" + (which "bash") + rust-src-path + (canonicalize-path wrapped-file)))) + (chmod prog-tmp #o755) + (rename-file prog-tmp prog)))))) (replace 'install-license-files (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) @@ -1416,6 +1440,7 @@ (define-public rust-analyzer (chdir "../..") (install-file "LICENSE-MIT" doc) (install-file "LICENSE-APACHE" doc))))))) + (native-inputs (list rust-src)) (home-page "https://rust-analyzer.github.io/") (synopsis "Experimental Rust compiler front-end for IDEs") (description "Rust-analyzer is a modular compiler frontend for the Rust diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm index 739ffb3192..5a6d4a5c30 100644 --- a/gnu/packages/rust.scm +++ b/gnu/packages/rust.scm @@ -13,6 +13,7 @@ ;;; Copyright © 2020 Matthew James Kraai ;;; Copyright © 2021 Maxim Cournoyer ;;; Copyright © 2021 (unmatched parenthesis +;;; Copyright © 2022 Zheng Junjie <873216071@qq.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -49,6 +50,7 @@ (define-module (gnu packages rust) #:use-module (gnu packages tls) #:use-module (gnu packages) #:use-module (guix build-system cargo) + #:use-module (guix build-system copy) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #:use-module (guix download) @@ -787,3 +789,21 @@ (define rust-1.57 ;;; be relied upon. This is to ease maintenance and reduce the time ;;; required to build the full Rust bootstrap chain. (define-public rust rust-1.57) + +(define-public rust-src + (hidden-package + (package + (inherit rust) + (name "rust-src") + (build-system copy-build-system) + (native-inputs '()) + (inputs '()) + (native-search-paths '()) + (outputs '("out")) + (arguments + `(#:install-plan + '(("library" "lib/rustlib/src/rust/library") + ("src" "lib/rustlib/src/rust/src")))) + (synopsis "Source code for the Rust standard library") + (description "This package provide source code for the Rust standard +library, only use by rust-analyzer, make rust-analyzer out of the box.")))) -- 2.34.0