From: John Soo <jsoo1@asu.edu>
To: 46162@debbugs.gnu.org
Subject: [bug#46162] [PATCH] staging gnu: Add more tools to rust outputs.
Date: Thu, 28 Jan 2021 15:29:54 -0800 [thread overview]
Message-ID: <875z3gk5cd.fsf@asu.edu> (raw)
In-Reply-To: <87eei4k9hn.fsf@asu.edu> (John Soo's message of "Thu, 28 Jan 2021 14:00:20 -0800")
[-- Attachment #1.1: Type: text/plain, Size: 75 bytes --]
Here is an edited patch. I had rebased incorrectly, my apologies.
- John
[-- Attachment #1.2: 0001-gnu-Add-more-tools-to-rust-outputs.patch --]
[-- Type: text/x-patch, Size: 9588 bytes --]
From cd3bddf4785f9efac275424c5c735092600f45c5 Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Wed, 25 Nov 2020 06:25:43 -0800
Subject: [PATCH] gnu: Add more tools to rust outputs.
The goal is to provide standard rust tools as outputs of rustc. The tools we
were missing were rls, clippy, src, and rust-analyzer.
* gnu/packages/rust.scm (rust-1.46): [outputs] add rls, clippy, src, and
rust-analyzer, [arguments] alter phases to build, test, and install each new
output, [arguments] patch RUNPATHS of outputs that require it, [arguments]
delete all uninstall scripts from outputs, [arguments] delete all the install
logs and manifests.
---
gnu/packages/rust.scm | 131 +++++++++++++++++++++++++++++++-----------
1 file changed, 97 insertions(+), 34 deletions(-)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index e646cd0091..b59fe98546 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -11,6 +11,7 @@
;;; Copyright © 2020, 2021 Jakub Kądziołka <kuba@kadziolka.net>
;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2020 Matthew Kraai <kraai@ftbfs.org>
+;;; Copyright © 2021 John Soo <jsoo1@asu.edu>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1322,19 +1323,41 @@ move around."
"0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid")))
(package
(inherit base-rust)
- (outputs (cons "rustfmt" (package-outputs base-rust)))
+ (outputs (append '("rustfmt" "rls" "src" "clippy" "rust-analyzer")
+ (package-outputs base-rust)))
+ (inputs
+ `(("gcc-lib" ,gcc "lib")
+ ,@(package-inputs base-rust)))
+ (native-inputs
+ `(("patchelf" ,patchelf)
+ ,@(package-native-inputs base-rust)))
(arguments
(substitute-keyword-arguments (package-arguments base-rust)
((#:phases phases)
`(modify-phases ,phases
+ (replace 'patch-cargo-checksums
+ ;; Generate checksums after patching generated files (in
+ ;; particular, vendor/jemalloc/rep/Makefile).
+ (lambda* _
+ (use-modules (guix build cargo-utils))
+ (substitute* '("Cargo.lock"
+ "src/tools/rust-analyzer/Cargo.lock")
+ (("(checksum = )\".*\"" all name)
+ (string-append name "\"" ,%cargo-reference-hash "\"")))
+ (generate-all-checksums "vendor")
+ #t))
(replace 'build
(lambda* _
(invoke "./x.py" "build")
(invoke "./x.py" "build" "src/tools/cargo")
- (invoke "./x.py" "build" "src/tools/rustfmt")))
+ (invoke "./x.py" "build" "src/tools/rustfmt")
+ (invoke "./x.py" "build" "src/tools/clippy")
+ (invoke "./x.py" "build" "src/tools/rls")
+ (invoke "./x.py" "build"
+ "src/tools/rust-analyzer/crates/rust-analyzer")))
(replace 'check
(lambda* _
- ;; Test rustfmt.
+ ;; Enable parallel execution.
(let ((parallel-job-spec
(string-append "-j" (number->string
(min 4
@@ -1343,44 +1366,84 @@ move around."
(invoke "./x.py" parallel-job-spec "test"
"src/tools/cargo")
(invoke "./x.py" parallel-job-spec "test"
- "src/tools/rustfmt"))))
+ "src/tools/rustfmt")
+ ;; Clippy tests do not work. See
+ ;; https://github.com/rust-lang/rust/issues/78717
+ ;; Even with --stage 1, they fail to compile
+ ;; (invoke "./x.py" parallel-job-spec "test" "--stage" "1"
+ ;; "src/tools/clippy")
+ (substitute* "src/tools/rls/tests/client.rs"
+ (("fn client_dependency_typo_and_fix" all)
+ (string-append "#[ignore]\n" all)))
+ (invoke "./x.py" parallel-job-spec "test"
+ "src/tools/rls"))))
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(invoke "./x.py" "install")
+ (for-each delete-file-recursively
+ (find-files (assoc-ref outputs "out")
+ "^uninstall\\.sh$"))
(substitute* "config.toml"
;; replace prefix to specific output
- (("prefix = \"[^\"]*\"")
- (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
- (invoke "./x.py" "install" "cargo")
- (substitute* "config.toml"
- ;; replace prefix to specific output
- (("prefix = \"[^\"]*\"")
- (string-append "prefix = \"" (assoc-ref outputs "rustfmt") "\"")))
- (invoke "./x.py" "install" "rustfmt")))
+ (("\\[build\\]" all)
+ (string-append all "
+extended = true
+tools =
+")))
+ (define (install-component component)
+ (substitute* "config.toml"
+ ;; replace prefix to specific output
+ (("(tools =).*" all tools)
+ (string-append tools " [\"" component "\"]\n"))
+ (("prefix = \"[^\"]*\"")
+ (string-append
+ "prefix = \"" (assoc-ref outputs component) "\"")))
+ (mkdir-p (assoc-ref outputs component))
+ (invoke "./x.py" "install" component)
+ (for-each delete-file-recursively
+ (find-files (assoc-ref outputs component)
+ "uninstall\\.sh")))
+ (for-each install-component
+ '("cargo"
+ "rustfmt"
+ "clippy"
+ "rls"
+ "src"
+ "rust-analyzer"))
+ #t))
+ (add-after 'install 'patch-tools-runpaths
+ (lambda* (#:key outputs inputs #:allow-other-keys)
+ (use-modules (ice-9 popen)
+ (ice-9 textual-ports))
+ (define (patch-path path)
+ (let* ((read-rpath
+ (string-append
+ "patchelf --print-rpath " path))
+ (pipe (open-input-pipe read-rpath))
+ (current-rpath (get-string-all pipe))
+ (out (assoc-ref outputs "out"))
+ (libc (assoc-ref inputs "libc"))
+ (gcc-lib (assoc-ref inputs "gcc-lib")))
+ (close-pipe pipe)
+ (invoke "patchelf" "--set-rpath"
+ (string-append current-rpath
+ ":" out "/lib"
+ ":" libc "/lib"
+ ":" gcc-lib "/lib")
+ path)))
+ (define (patch-component component)
+ (for-each patch-path
+ (find-files (assoc-ref outputs component)
+ (lambda (p s) (executable-file? p)))))
+ (for-each patch-component '("clippy" "rls"))))
(replace 'delete-install-logs
(lambda* (#:key outputs #:allow-other-keys)
- (define (delete-manifest-file out-path file)
- (delete-file (string-append out-path "/lib/rustlib/" file)))
-
- (let ((out (assoc-ref outputs "out"))
- (cargo-out (assoc-ref outputs "cargo"))
- (rustfmt-out (assoc-ref outputs "rustfmt")))
- (for-each
- (lambda (file) (delete-manifest-file out file))
- '("install.log"
- "manifest-rust-docs"
- ,(string-append "manifest-rust-std-"
- (nix-system->gnu-triplet-for-rust))
- "manifest-rustc"))
- (for-each
- (lambda (file) (delete-manifest-file cargo-out file))
- '("install.log"
- "manifest-cargo"))
- (for-each
- (lambda (file) (delete-manifest-file rustfmt-out file))
- '("install.log"
- "manifest-rustfmt-preview"))
- #t))))))))))
+ (define log-manifest-re
+ "^install\\.log$|^manifest-([a-z]|[0-9]|_|-)+(-preview)?$")
+ (define (delete-install-log output)
+ (for-each delete-file-recursively
+ (find-files output log-manifest-re)))
+ (for-each delete-install-log (map cdr outputs)))))))))))
(define-public rust-1.47
(let ((base-rust
--
2.30.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]
next prev parent reply other threads:[~2021-01-28 23:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 22:00 [bug#46162] [PATCH] staging gnu: Add more tools to rust outputs John Soo
2021-01-28 23:29 ` John Soo [this message]
2021-02-15 16:13 ` John Soo
2021-02-15 18:09 ` John Soo
2021-02-15 23:41 ` Jakub Kądziołka
2021-02-16 16:40 ` John Soo
2021-02-16 16:41 ` Jakub Kądziołka
2021-02-18 18:01 ` Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875z3gk5cd.fsf@asu.edu \
--to=jsoo1@asu.edu \
--cc=46162@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.