diff mbox series

[bug#39445,v2,2/2] gnu: ripgrep: enable the 'pcre2' feature

Message ID 20200209215110.6755-2-kuba@kadziolka.net
State Accepted
Headers show
Series [bug#39445,v2,1/2] gnu: ripgrep: Install the manpage. | expand

Checks

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

Commit Message

Maja Kądziołka Feb. 9, 2020, 9:51 p.m. UTC
* gnu/packages/rust-apps.scm (ripgrep)[arguments]: Add
  #:cargo-build-flags to specify the feature. Replace the 'install phase
  to work around the cargo-build-system a bit.
---
 gnu/packages/rust-apps.scm | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Comments

Efraim Flashner Feb. 10, 2020, 8:43 a.m. UTC | #1
Should the install phase also get the '--release' flag?

On Sun, Feb 09, 2020 at 10:51:10PM +0100, Jakub Kądziołka wrote:
> * gnu/packages/rust-apps.scm (ripgrep)[arguments]: Add
>   #:cargo-build-flags to specify the feature. Replace the 'install phase
>   to work around the cargo-build-system a bit.
> ---
>  gnu/packages/rust-apps.scm | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm
> index ddc9f6ed37..26b5445d98 100644
> --- a/gnu/packages/rust-apps.scm
> +++ b/gnu/packages/rust-apps.scm
> @@ -242,9 +242,21 @@ provides defaults for 80% of the use cases.")
>                  (install-file manpage (string-append
>                                          (assoc-ref outputs "out")
>                                          "/share/man/man1"))))
> -             #t)))))
> +             #t))
> +         (replace 'install
> +           ;; Adapted from (guix build cargo-build-system). The flags need to
> +           ;; be passed to `cargo install' too, as otherwise it will build
> +           ;; another binary, without the features.
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let ((out (assoc-ref outputs "out")))
> +               (mkdir-p out)
> +               (setenv "CARGO_TARGET_DIR" "./target")
> +               (invoke "cargo" "install" "--path" "." "--root" out
> +                       "--features" "pcre2")))))
> +       #:cargo-build-flags '("--release" "--features" "pcre2")))
>      (native-inputs
> -     `(("asciidoc" ,asciidoc)))
> +     `(("asciidoc" ,asciidoc)
> +       ,@(package-native-inputs rust-pcre2-sys-0.2)))
>      (home-page "https://github.com/BurntSushi/ripgrep")
>      (synopsis "Line-oriented search tool")
>      (description
> -- 
> 2.25.0
> 
> 
> 
>
Maja Kądziołka Feb. 10, 2020, 11:28 a.m. UTC | #2
On Mon, Feb 10, 2020 at 10:43:51AM +0200, Efraim Flashner wrote:
> Should the install phase also get the '--release' flag?

It's a reasonable question to ask, but no. `cargo install' will always
use a release build. Moreover, passing the --release flag to cargo
install will lead to an unexpected argument error.

Regards,
Jakub Kądziołka
Efraim Flashner Feb. 11, 2020, 6:25 p.m. UTC | #3
On Mon, Feb 10, 2020 at 12:28:13PM +0100, Jakub Kądziołka wrote:
> On Mon, Feb 10, 2020 at 10:43:51AM +0200, Efraim Flashner wrote:
> > Should the install phase also get the '--release' flag?
> 
> It's a reasonable question to ask, but no. `cargo install' will always
> use a release build. Moreover, passing the --release flag to cargo
> install will lead to an unexpected argument error.

That's unfortunate. I was hoping to re-use the cargo-build-flags option.
Might still be worth it, after adding logic to strip out the '--release'
flag.

Patches pushed.
diff mbox series

Patch

diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm
index ddc9f6ed37..26b5445d98 100644
--- a/gnu/packages/rust-apps.scm
+++ b/gnu/packages/rust-apps.scm
@@ -242,9 +242,21 @@  provides defaults for 80% of the use cases.")
                 (install-file manpage (string-append
                                         (assoc-ref outputs "out")
                                         "/share/man/man1"))))
-             #t)))))
+             #t))
+         (replace 'install
+           ;; Adapted from (guix build cargo-build-system). The flags need to
+           ;; be passed to `cargo install' too, as otherwise it will build
+           ;; another binary, without the features.
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (mkdir-p out)
+               (setenv "CARGO_TARGET_DIR" "./target")
+               (invoke "cargo" "install" "--path" "." "--root" out
+                       "--features" "pcre2")))))
+       #:cargo-build-flags '("--release" "--features" "pcre2")))
     (native-inputs
-     `(("asciidoc" ,asciidoc)))
+     `(("asciidoc" ,asciidoc)
+       ,@(package-native-inputs rust-pcre2-sys-0.2)))
     (home-page "https://github.com/BurntSushi/ripgrep")
     (synopsis "Line-oriented search tool")
     (description