From unknown Fri Aug 15 15:59:14 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#39959] [PATCH] cargo-build-system: Accept a #:features argument Resent-From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 06 Mar 2020 21:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39959 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 39959@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.158353145315189 (code B ref -1); Fri, 06 Mar 2020 21:51:02 +0000 Received: (at submit) by debbugs.gnu.org; 6 Mar 2020 21:50:53 +0000 Received: from localhost ([127.0.0.1]:45964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAKrs-0003wv-Ky for submit@debbugs.gnu.org; Fri, 06 Mar 2020 16:50:52 -0500 Received: from lists.gnu.org ([209.51.188.17]:41568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAKrp-0003wm-Ny for submit@debbugs.gnu.org; Fri, 06 Mar 2020 16:50:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41689) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAKro-0005HA-8q for guix-patches@gnu.org; Fri, 06 Mar 2020 16:50:49 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAKrl-0003Bz-Uk for guix-patches@gnu.org; Fri, 06 Mar 2020 16:50:48 -0500 Received: from pat.zlotemysli.pl ([37.59.186.212]:52508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jAKrl-00039E-AD for guix-patches@gnu.org; Fri, 06 Mar 2020 16:50:45 -0500 Received: (qmail 9872 invoked by uid 1009); 6 Mar 2020 22:44:00 +0100 Received: from 188.123.215.55 (kuba@kadziolka.net@188.123.215.55) by pat (envelope-from , uid 1002) with qmail-scanner-2.08st (clamdscan: 0.98.6/25742. spamassassin: 3.4.0. perlscan: 2.08st. Clear:RC:1(188.123.215.55):. Processed in 0.008807 secs); 06 Mar 2020 21:44:00 -0000 Received: from unknown (HELO localhost.localdomain) (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 6 Mar 2020 22:44:00 +0100 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Fri, 6 Mar 2020 22:44:49 +0100 Message-Id: <20200306214449.4887-1-kuba@kadziolka.net> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Qmailux-2.08st: added fake Content-Type header Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 37.59.186.212 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * 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. --- I am looking into packaging rustup, which, like ripgrep, also needs to pass a --features argument to cargo. This suggests that proper support for it in the build system is warranted. In #39445, Efraim suggested using cargo-build-flags as an argument to "cargo install". Alas, the --release flag is not accepted by "cargo install" at all, which makes a design like this necessary. Unresolved question: can this be merged directly to master? There are exactly 300 hits for cargo-build-system in gnu/packages/{rust-apps,crates-io}.scm if we exclude all the libraries with #:skip-build? #t. 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 72c982f23c..fa02ded8ec 100644 --- a/gnu/packages/rust-apps.scm +++ b/gnu/packages/rust-apps.scm @@ -243,18 +243,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 From unknown Fri Aug 15 15:59:14 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Subject: bug#39959: closed (Done: [PATCH] cargo-build-system: Accept a #:features argument) Message-ID: References: <20200323222846.ri7rhvzrtgiexwcf@gravity> <20200306214449.4887-1-kuba@kadziolka.net> X-Gnu-PR-Message: they-closed 39959 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 39959@debbugs.gnu.org Date: Mon, 23 Mar 2020 22:29:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1585002542-3944-1" This is a multi-part message in MIME format... ------------=_1585002542-3944-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #39959: [PATCH] cargo-build-system: Accept a #:features argument which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 39959@debbugs.gnu.org. --=20 39959: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D39959 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1585002542-3944-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 39959-done) by debbugs.gnu.org; 23 Mar 2020 22:28:53 +0000 Received: from localhost ([127.0.0.1]:53655 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jGVYy-00011H-R2 for submit@debbugs.gnu.org; Mon, 23 Mar 2020 18:28:53 -0400 Received: from pat.zlotemysli.pl ([37.59.186.212]:38136) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jGVYw-000117-Hu for 39959-done@debbugs.gnu.org; Mon, 23 Mar 2020 18:28:51 -0400 Received: (qmail 32252 invoked by uid 1009); 23 Mar 2020 23:28:48 +0100 Received: from 188.123.215.55 (kuba@kadziolka.net@188.123.215.55) by pat (envelope-from , uid 1002) with qmail-scanner-2.08st (clamdscan: 0.98.6/25759. spamassassin: 3.4.0. perlscan: 2.08st. Clear:RC:1(188.123.215.55):. Processed in 0.021191 secs); 23 Mar 2020 22:28:48 -0000 Received: from unknown (HELO gravity) (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl with SMTP; 23 Mar 2020 23:28:48 +0100 Date: Mon, 23 Mar 2020 23:28:46 +0100 From: Jakub =?utf-8?B?S8SFZHppb8WCa2E=?= To: 39959-done@debbugs.gnu.org Subject: Done: [PATCH] cargo-build-system: Accept a #:features argument Message-ID: <20200323222846.ri7rhvzrtgiexwcf@gravity> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ioq2gamwrpyt7wiv" Content-Disposition: inline X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39959-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --ioq2gamwrpyt7wiv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Pushed to staging as 927c2518465579d48315e8e6b5102097c146fece. --ioq2gamwrpyt7wiv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE5Xa/ss9usT31cTO54xWnWEYTFWQFAl55OBoACgkQ4xWnWEYT FWTLOA/+Pojm6F6izIFftyuDjV01mmVGV8aYUmohp8CaJIuAVUzRx+nh3s+Oayic 0So8vAg8dbzjnttzo5z8sUsIoRoGGa92JbMT9jD+Z89J/hRhLp0Y6UNm+v+8R/uC pa2ybM+eB4F2+MPry6koYSrZdWBNLNtIqNNX6QoV0r5lua+QAcQqceMR8n7Hxrm+ aQ/iNztB837E1JwvZ6blgggVywmskbXZ+LhGnBUh8jmAHGQAxakXA7EnE2t9tuks GqjX5BvC/VW7TywfirNcEeDuuXJpIf5hWX+s8YRv5W/8Ks1QpNtACouJtLbqYb2J fdwfnOBNQnR3xcLZGKsZXqjROzT66OgjXz6fS10RdIagkEZS/CvnM3a6y7iRuPTg Mv1q01ClC9sf0JGd35M75GZxz9TY38DzRUkkfMVXiXDbrlaUt3+bF6SUfll9oC7f ku+8fEAkWdANQwClH7xk/XHpVITeXHq+bTdqyXAoVCSllfUiVaC+V2ikDFo/hQgF Wnly914Gn0s27C3qunpMte56lJvODj5xbTTMGO0+rsvVxZd1CPfVtlmqNfaV3zpi 7EejCBNgpv5CJVtABis8VNCcWEudArOX17GV2ATz8nxZ0EPOR5tNdYyD+lKBZxB2 UbA9N/D2Kf7LIA2rYDzAxTOyvQ+oFF1F4gCZdh2v0jm8GZKrazE= =pqsz -----END PGP SIGNATURE----- --ioq2gamwrpyt7wiv-- ------------=_1585002542-3944-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 6 Mar 2020 21:50:53 +0000 Received: from localhost ([127.0.0.1]:45964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAKrs-0003wv-Ky for submit@debbugs.gnu.org; Fri, 06 Mar 2020 16:50:52 -0500 Received: from lists.gnu.org ([209.51.188.17]:41568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAKrp-0003wm-Ny for submit@debbugs.gnu.org; Fri, 06 Mar 2020 16:50:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41689) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAKro-0005HA-8q for guix-patches@gnu.org; Fri, 06 Mar 2020 16:50:49 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAKrl-0003Bz-Uk for guix-patches@gnu.org; Fri, 06 Mar 2020 16:50:48 -0500 Received: from pat.zlotemysli.pl ([37.59.186.212]:52508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jAKrl-00039E-AD for guix-patches@gnu.org; Fri, 06 Mar 2020 16:50:45 -0500 Received: (qmail 9872 invoked by uid 1009); 6 Mar 2020 22:44:00 +0100 Received: from 188.123.215.55 (kuba@kadziolka.net@188.123.215.55) by pat (envelope-from , uid 1002) with qmail-scanner-2.08st (clamdscan: 0.98.6/25742. spamassassin: 3.4.0. perlscan: 2.08st. Clear:RC:1(188.123.215.55):. Processed in 0.008807 secs); 06 Mar 2020 21:44:00 -0000 Received: from unknown (HELO localhost.localdomain) (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 6 Mar 2020 22:44:00 +0100 From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= To: guix-patches@gnu.org Subject: [PATCH] cargo-build-system: Accept a #:features argument Date: Fri, 6 Mar 2020 22:44:49 +0100 Message-Id: <20200306214449.4887-1-kuba@kadziolka.net> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Qmailux-2.08st: added fake Content-Type header Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 37.59.186.212 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * 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. --- I am looking into packaging rustup, which, like ripgrep, also needs to pass a --features argument to cargo. This suggests that proper support for it in the build system is warranted. In #39445, Efraim suggested using cargo-build-flags as an argument to "cargo install". Alas, the --release flag is not accepted by "cargo install" at all, which makes a design like this necessary. Unresolved question: can this be merged directly to master? There are exactly 300 hits for cargo-build-system in gnu/packages/{rust-apps,crates-io}.scm if we exclude all the libraries with #:skip-build? #t. 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 72c982f23c..fa02ded8ec 100644 --- a/gnu/packages/rust-apps.scm +++ b/gnu/packages/rust-apps.scm @@ -243,18 +243,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 ------------=_1585002542-3944-1--