diff mbox series

[bug#42295] gnu: rust-1.44: Add rustfmt output.

Message ID 5407eb2f-b499-2520-e0e5-48ca7171e6bd@ftbfs.org
State Accepted
Headers show
Series [bug#42295] gnu: rust-1.44: Add rustfmt output. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Matthew Kraai Nov. 26, 2020, 1:25 p.m. UTC
Hi John,

On 11/25/20 6:46 AM, John Soo wrote:
> Hi Matthew,
>
> Thanks! I had packaged rustfmt-nightly but this is much better.
>
> Matthew Kraai <kraai@ftbfs.org> writes:
>
>> +             (replace 'check
>> +               (lambda* _
>> +                 ;; Enable parallel execution.
>> +                 (let ((parallel-job-spec
>> +                        (string-append "-j" (number->string
>> +                                             (min 4
>> +                                                  (parallel-job-count))))))
>> +                   (invoke "./x.py" parallel-job-spec "test" "-vv")
>> +                   (invoke "./x.py" parallel-job-spec "test"
>> +                           "src/tools/cargo")
>> +                   (invoke "./x.py" parallel-job-spec "test"
>> +                           "src/tools/rustfmt"))))
> Nice!
>
>> +      (outputs '("out" "doc" "cargo" "rustfmt"))
> Perhaps we should make anything that can be installed as a rustup
> component an output (provided the source is in the rust tree). I think
> rls can be added immediately in the same fashion.
Is rls deprecated in favor of rust-analyzer?
> Do you want to add a copyright line?
Done.
> Otherwise, this looks good to me.

According to https://github.com/rust-lang/rustfmt, rustfmt was made a 
component in 1.24.0.  Would it be better to add this support to the 
rust-1.24 package instead?  I've attached the patch I'm currently testing.
diff mbox series

Patch

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 05404de1d8..d7a26d2f46 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -10,6 +10,7 @@ 
 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2020 Matthew Kraai <kraai@ftbfs.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -690,6 +691,7 @@  jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
           "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
     (package
       (inherit base-rust)
+      (outputs (cons "rustfmt" (package-outputs base-rust)))
       (arguments
        (substitute-keyword-arguments (package-arguments base-rust)
          ((#:phases phases)
@@ -701,7 +703,36 @@  jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
                    ;; This test is known to fail on aarch64 and powerpc64le:
                    ;; https://github.com/rust-lang/rust/issues/45410
                    (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
-                 #t)))))))))
+                 #t))
+             (add-after 'configure 'enable-extended-build
+               (lambda* _
+                 (substitute* "config.toml"
+                   (("[[]build[]]") "[build]\nextended = true"))
+                 #t))
+             (replace 'build
+               (lambda* _
+                 (invoke "./x.py" "build")
+                 (invoke "./x.py" "build" "src/tools/cargo")
+                 (invoke "./x.py" "build" "src/tools/rustfmt")))
+             (replace 'check
+               (lambda* _
+                 (invoke "./x.py" "-j1" "test" "-vv")
+                 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
+                 (invoke "./x.py" "-j1" "test" "src/tools/rustfmt")
+                 #t))
+             (replace 'install
+               (lambda* (#:key outputs #:allow-other-keys)
+                 (invoke "./x.py" "install")
+                 (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"))))))))))
 
 ;;; Rust 1.25 release support work with llvm 6--but build with llvm 6 is
 ;;; not determenistic due to <https://github.com/rust-lang/rust/issues/50556>.
@@ -764,6 +795,7 @@  jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
           `(modify-phases ,phases
              ;; binaryen was replaced with LLD project from LLVM
              (delete 'dont-build-native)
+             (delete 'enable-extended-build)
              (replace 'check
                (lambda* _
                  ;; Enable parallel execution.
@@ -773,7 +805,9 @@  jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
                                                   (parallel-job-count))))))
                    (invoke "./x.py" parallel-job-spec "test" "-vv")
                    (invoke "./x.py" parallel-job-spec "test"
-                           "src/tools/cargo"))))
+                           "src/tools/cargo")
+                   (invoke "./x.py" parallel-job-spec "test"
+                           "src/tools/rustfmt"))))
              (replace 'remove-unsupported-tests
                (lambda* _
                  ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
@@ -844,6 +878,7 @@  jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
                  ;; `prefix' directory should exist before `install' call
                  (mkdir-p (assoc-ref outputs "out"))
                  (mkdir-p (assoc-ref outputs "cargo"))
+                 (mkdir-p (assoc-ref outputs "rustfmt"))
                  #t))
              (add-after 'patch-cargo-tests 'disable-thinlto-test
                (lambda* _