From patchwork Fri Mar 6 21:44:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Maja_K=C4=85dzio=C5=82ka?= X-Patchwork-Id: 20555 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5B6F427BBEA; Fri, 6 Mar 2020 21:51:14 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id C222D27BBE4 for ; Fri, 6 Mar 2020 21:51:13 +0000 (GMT) Received: from localhost ([::1]:42694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAKsD-0005HX-8I for patchwork@mira.cbaines.net; Fri, 06 Mar 2020 16:51:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41856) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAKs5-0005HN-5e for guix-patches@gnu.org; Fri, 06 Mar 2020 16:51:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAKs3-0003O8-CM for guix-patches@gnu.org; Fri, 06 Mar 2020 16:51:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:39991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jAKs2-0003N8-Aq for guix-patches@gnu.org; Fri, 06 Mar 2020 16:51:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jAKs2-0003xK-85 for guix-patches@gnu.org; Fri, 06 Mar 2020 16:51:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#39959] [PATCH] cargo-build-system: Accept a #:features argument Resent-From: Jakub =?utf-8?b?S8SFZHppb8WCa2E=?= 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 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?b?S8SFZHppb8WCa2E=?= 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 X-Qmailux-2.08st: added fake Content-Type header X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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