From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:41961) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEvcZ-0002kT-4z for guix-patches@gnu.org; Thu, 19 Mar 2020 09:54:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEvcY-0005Cg-06 for guix-patches@gnu.org; Thu, 19 Mar 2020 09:54:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEvcX-0005CM-TJ for guix-patches@gnu.org; Thu, 19 Mar 2020 09:54:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jEvcX-0006uM-QS for guix-patches@gnu.org; Thu, 19 Mar 2020 09:54:01 -0400 Subject: [bug#40131] [PATCH staging] cargo-build-system: Accept a #:features argument Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:41833) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEvbu-0002ik-5b for guix-patches@gnu.org; Thu, 19 Mar 2020 09:53:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEvbs-0003zD-V0 for guix-patches@gnu.org; Thu, 19 Mar 2020 09:53:22 -0400 Received: from pat.zlotemysli.pl ([37.59.186.212]:50260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jEvbs-0003xX-MU for guix-patches@gnu.org; Thu, 19 Mar 2020 09:53:20 -0400 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Thu, 19 Mar 2020 14:53:15 +0100 Message-Id: <20200319135315.17573-1-kuba@kadziolka.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 40131@debbugs.gnu.org * guix/build/cargo-build-system.scm (build, install): Pass the features to cargo. (check): Remove indirection layer for consistency with build and install. * guix/build-system/cargo.scm (cargo-build): New argument; pass it into the builder. * gnu/packages/rust-apps.scm (ripgrep): Use the new argument instead of a custom phase. --- gnu/packages/rust-apps.scm | 14 ++------------ guix/build-system/cargo.scm | 2 ++ guix/build/cargo-build-system.scm | 12 ++++++++---- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm index af51c0fcfc..2c718a14f5 100644 --- a/gnu/packages/rust-apps.scm +++ b/gnu/packages/rust-apps.scm @@ -244,18 +244,8 @@ provides defaults for 80% of the use cases.") (install-file manpage (string-append (assoc-ref outputs "out") "/share/man/man1")))) - #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"))) + #t))) + #:features '("pcre2"))) (native-inputs `(("asciidoc" ,asciidoc) ("pcre2" ,pcre2) diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm index 1e8b3a578e..2b5f301dc2 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -76,6 +76,7 @@ to NAME and VERSION." (vendor-dir "guix-vendor") (cargo-build-flags ''("--release")) (cargo-test-flags ''("--release")) + (features ''()) (skip-build? #f) (phases '(@ (guix build cargo-build-system) %standard-phases)) @@ -104,6 +105,7 @@ to NAME and VERSION." #:vendor-dir ,vendor-dir #:cargo-build-flags ,cargo-build-flags #:cargo-test-flags ,cargo-test-flags + #:features ,features #:skip-build? ,skip-build? #:tests? ,(and tests? (not skip-build?)) #:phases ,phases diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 0721989589..0e2faee3c1 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -140,11 +140,14 @@ directory = '" port) (define* (build #:key skip-build? + features (cargo-build-flags '("--release")) #:allow-other-keys) "Build a given Cargo package." (or skip-build? - (apply invoke `("cargo" "build" ,@cargo-build-flags)))) + (apply invoke "cargo" "build" + "--features" (string-join features) + cargo-build-flags))) (define* (check #:key tests? @@ -152,10 +155,10 @@ directory = '" port) #:allow-other-keys) "Run tests for a given Cargo package." (if tests? - (apply invoke `("cargo" "test" ,@cargo-test-flags)) + (apply invoke "cargo" "test" cargo-test-flags) #t)) -(define* (install #:key inputs outputs skip-build? #:allow-other-keys) +(define* (install #:key inputs outputs skip-build? features #:allow-other-keys) "Install a given Cargo package." (let* ((out (assoc-ref outputs "out"))) (mkdir-p out) @@ -168,7 +171,8 @@ directory = '" port) ;; otherwise cargo will raise an error. (or skip-build? (not (has-executable-target?)) - (invoke "cargo" "install" "--path" "." "--root" out)))) + (invoke "cargo" "install" "--path" "." "--root" out + "--features" (string-join features))))) (define %standard-phases (modify-phases gnu:%standard-phases -- 2.25.1