[bug#77093,rust-team,03/18] build-system: cargo: Support packaging Cargo workspace.
Message ID | Z9ldu8IeBWVna2xO@3900XT |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E54F627BBE2; Tue, 18 Mar 2025 11:50:55 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2370C27BBEE for <patchwork@mira.cbaines.net>; Tue, 18 Mar 2025 11:50:52 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1tuVST-0003BB-Fw; Tue, 18 Mar 2025 07:50:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tuVSP-00038s-Ea for guix-patches@gnu.org; Tue, 18 Mar 2025 07:50:05 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tuVSP-0002Sq-0y for guix-patches@gnu.org; Tue, 18 Mar 2025 07:50:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:MIME-Version:References:From:Date:To:Subject; bh=j0Al9m0lmaIqvOfqwpYIA5G/L+lEu2oTEJonIfXs6vw=; b=GMlEOGHr/qKKN391Rd7p+OyU4s5gXA8AgrTwavP/DqR94DcOX+iS5UEabS4HPblQNoES+qv6nNCFzK00026iB1oWkGLdzfbtKvk+t/KfbqVsB8mdwrp6e2IEw5tc19hCP9BlSeY2iwxkzjfuq0OrNFWB9ImluCdqj+X98trZSH+EBQvRkNUWTY2OR/FvuDuk+91zTZGkzQSr0i8tBxeJZgcXN2Ja5RL0MRbkRbXIz+yl4zWK+hQ5ic8vFP40t5Y9CjEvL9O26hr3jOhdubhRNmenv4qBu+WZ88B0sVG8oNXfT+2C1R4SB0VrMCSZWH9Rt7gTrZm526evQj1/wDYJWA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tuVSO-0008Sg-FA for guix-patches@gnu.org; Tue, 18 Mar 2025 07:50:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 03/18] build-system: cargo: Support packaging Cargo workspace. Resent-From: Efraim Flashner <efraim@flashner.co.il> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 11:50:04 +0000 Resent-Message-ID: <handler.77093.B77093.174229857432203@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Hilton Chain <hako@ultrarare.space> Cc: Steve George <steve@futurile.net>, Ludovic =?utf-8?q?Court=C3=A8s?= <ludo@gnu.org>, Maxim Cournoyer <maxim.cournoyer@gmail.com>, 77093@debbugs.gnu.org, Divya Ranjan Pattanaik <divya@subvertising.org> Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174229857432203 (code B ref 77093); Tue, 18 Mar 2025 11:50:04 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 11:49:34 +0000 Received: from localhost ([127.0.0.1]:37686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1tuVRp-0008Me-Od for submit@debbugs.gnu.org; Tue, 18 Mar 2025 07:49:33 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:50450) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <efraim.flashner@gmail.com>) id 1tuVRk-0008LE-5r for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 07:49:27 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-391211ea598so3067278f8f.1 for <77093@debbugs.gnu.org>; Tue, 18 Mar 2025 04:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742298558; x=1742903358; darn=debbugs.gnu.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to :cc:subject:date:message-id:reply-to; bh=j0Al9m0lmaIqvOfqwpYIA5G/L+lEu2oTEJonIfXs6vw=; b=Et6I5hqLNfm4nnSuTouqUUm4CYdbSgmUyPO5BHgMmK0JULqoWp0lR/xbN8hnLWHOMc JgTvnrIyCR1x0uNAhhrqDQ8+ziq6fqQgc3xhhAl6KJ2Y6KriNFDXLyfQ3MGCheNM0iDL gkC8gzk0KSELGAw8I4BE2X1wYqofMj0npB39GsDe4Qo8w0lMs4Mo/hbsVxKLX0k8Vbgg 8/FPexB3i9UoBmywF48ALTySTPNstXTC8V9nO09Tf1HuVDwuU0rLoV3V6mUVVxgx8SAP n7rlGGnR8BcDoE7f7sDvDLAOPBOPoAmD7295zO2X95OJasdVAyfwjb0BF0I5sOuBG2j2 hD6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742298558; x=1742903358; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=j0Al9m0lmaIqvOfqwpYIA5G/L+lEu2oTEJonIfXs6vw=; b=j+I42TfqRZQJOiMXINQxfopY27j6abPz2IAMGANl+PuWcl+sZyDJS6D8YXDtMcCO1M WIPctq6HAarPHb4UnGJoCBzIf0RGc1Qdqye8+IvAKab9L2CwoICkdJkfHI3NAGWbmmfE Dt3JWBT6AvZCW7lF6b935/30YjSkrzhOWVLx1L5N5Kwy/ypttTtftDnvjS9rL6JVciMM JnZR/MEJ9UoZ/yu3XdRIG8yTXX/diu3YkmIPRSlRTEpCezBTb551nlTkVdX9MxiwZjsI ZpZ9s5+V11axNc8+TYVLJUVRiVZbRohdbivSYVWtlxl2/FGpzC3EI1HaXAIB91EIaRhW aYEA== X-Gm-Message-State: AOJu0YyshDTMVlniPuKsZtLJh5PczRzHrqpnS22w89B6+XmI763uYpJo v11v9vUE/5N3rMrpiNxNKtBz6w/l7/4YAsvVpl0AcFtGUfDeHZlF X-Gm-Gg: ASbGncuxWG+t9myqtaLwxKy15raCwdbl77j8PK972+gZNA76Fq48u+V7Kd+x390HSX1 9Y+DsEMf2ykMK6O3AR10/bppAXCjQWQ+ZBRNG0Fv+fFu5d2ihTDoOrG6erpIkpVsvmFS+AgZorO UvbDblMup+IzElbvQRy/6oDb/LAME9ZqvGkWjgMsOV37c9jNgXR/SNt0Dp1gdFnI+zTNNRWNAfQ nNYFC/oF/sJX73jQcQkhUIYT2GLDgcFnjhiUp+csabLXNVrulLyc7nfBvOPP6pvmqofSxjggBnz OBiVRokg4ieS+53S1V3WDsv5Gb9QcpH4ya6DJ8vCpXTBIQ== X-Google-Smtp-Source: AGHT+IGJpG2lE+s+ejFIyCywaCVp7WwWsY6KRoyYfr1wmN0qMjoWDDQdpbTDrj+FIUXilXLWapvDRw== X-Received: by 2002:a5d:64e7:0:b0:391:29c0:83f5 with SMTP id ffacd0b85a97d-39720d47357mr16363097f8f.44.1742298557511; Tue, 18 Mar 2025 04:49:17 -0700 (PDT) Received: from localhost ([188.120.128.147]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-397f2837e61sm12556286f8f.97.2025.03.18.04.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Mar 2025 04:49:16 -0700 (PDT) Date: Tue, 18 Mar 2025 13:49:15 +0200 From: Efraim Flashner <efraim@flashner.co.il> Message-ID: <Z9ldu8IeBWVna2xO@3900XT> Mail-Followup-To: Efraim Flashner <efraim@flashner.co.il>, Hilton Chain <hako@ultrarare.space>, 77093@debbugs.gnu.org, Divya Ranjan Pattanaik <divya@subvertising.org>, Ludovic =?utf-8?q?Court?= =?utf-8?q?=C3=A8s?= <ludo@gnu.org>, Maxim Cournoyer <maxim.cournoyer@gmail.com>, Steve George <steve@futurile.net> References: <cover.1742281797.git.hako@ultrarare.space> <0478229ef1b10a866b0c1cc9e33ec5bf27346d37.1742281797.git.hako@ultrarare.space> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QRwpcsKec1gQHr7t" Content-Disposition: inline In-Reply-To: <0478229ef1b10a866b0c1cc9e33ec5bf27346d37.1742281797.git.hako@ultrarare.space> X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
None
|
|
Commit Message
Efraim Flashner
March 18, 2025, 11:49 a.m. UTC
I've attached a diff that removes the need for RUSTC_BOOTSTRAP that seems to work when I rebuilt rust-pubgrub. Some links I followed: https://doc.rust-lang.org/cargo/commands/cargo-publish.html#package-selection https://github.com/rust-lang/cargo/issues/10948#issuecomment-1229236664 "One background knowledge: cargo publish is roughly `cargo package` + call crates.io API." Before and after: (ins)efraim@3900XT ~/workspace/guix-rust-team$ tree /gnu/store/zk1n23l2wdca8snz1wqllmjxv83hccl5-rust-pubgrub-0.3.0-0.b70cf70 | head /gnu/store/zk1n23l2wdca8snz1wqllmjxv83hccl5-rust-pubgrub-0.3.0-0.b70cf70 └── share ├── cargo │ ├── registry │ │ ├── pubgrub-0.3.0.crate │ │ └── version-ranges-0.1.1.crate │ └── src │ ├── pubgrub-0.3.0 │ │ ├── benches │ │ │ ├── backtracking.rs (ins)efraim@3900XT ~/workspace/guix-rust-team$ tree /gnu/store/9310sgn182cgqy4p1xkn2hi8x4wg0nn8-rust-pubgrub-0.3.0-0.b70cf70 | head /gnu/store/9310sgn182cgqy4p1xkn2hi8x4wg0nn8-rust-pubgrub-0.3.0-0.b70cf70 └── share ├── cargo │ ├── registry │ │ ├── pubgrub-0.3.0.crate │ │ └── version-ranges-0.1.1.crate │ └── src │ ├── pubgrub-0.3.0 │ │ ├── benches │ │ │ ├── backtracking.rs On Tue, Mar 18, 2025 at 03:24:16PM +0800, Hilton Chain wrote: > * guix/build-system/cargo.scm (cargo-build,cargo-cross-build) > [#:cargo-package-crates]: New argument. > * guix/build/cargo-build-system.scm (package): Use it. > * doc/guix.texi (Build Systems)[cargo-build-system]: Document it. > > Change-Id: I45ccd95e90827d47127015cb0bda2d41f792335b > --- > doc/guix.texi | 7 +++++++ > guix/build-system/cargo.scm | 4 ++++ > guix/build/cargo-build-system.scm | 28 ++++++++++++++++++++++++++-- > 3 files changed, 37 insertions(+), 2 deletions(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 0ca109a214..322512fd36 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -9363,6 +9363,13 @@ Build Systems > the binaries defined by the crate. Unless @code{install-source? #f} is > defined it will also install a source crate repository of itself and unpacked > sources, to ease in future hacking on rust packages. > + > +This build system supports cargo workspaces. Parameter > +@code{#:cargo-package-crates} (default: @code{''()}) allows specifying > +names of library crates to package in @code{package} phase. Specified > +crates are packaged from left to right, in case there's dependency among > +them. For example, specifying @code{''("pcre2-sys" "pcre2")} will > +package @code{"pcre2-sys"} first and then @code{"pcre2"}. > @end defvar > > @defvar chicken-build-system > diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm > index 452f7f78d0..4f6d46e70c 100644 > --- a/guix/build-system/cargo.scm > +++ b/guix/build-system/cargo.scm > @@ -94,6 +94,7 @@ (define* (cargo-build name inputs > (vendor-dir "guix-vendor") > (cargo-build-flags ''("--release")) > (cargo-test-flags ''()) > + (cargo-package-crates ''()) > (cargo-package-flags ''("--no-metadata" "--no-verify")) > (features ''()) > (skip-build? #f) > @@ -122,6 +123,7 @@ (define* (cargo-build name inputs > #:vendor-dir #$vendor-dir > #:cargo-build-flags #$(sexp->gexp cargo-build-flags) > #:cargo-test-flags #$(sexp->gexp cargo-test-flags) > + #:cargo-package-crates #$(sexp->gexp cargo-package-crates) > #:cargo-package-flags #$(sexp->gexp cargo-package-flags) > #:cargo-target #$(cargo-triplet system) > #:features #$(sexp->gexp features) > @@ -154,6 +156,7 @@ (define* (cargo-cross-build name > (vendor-dir "guix-vendor") > (cargo-build-flags ''("--release")) > (cargo-test-flags ''()) > + (cargo-package-crates ''()) > (cargo-package-flags ''("--no-metadata" "--no-verify")) > (cargo-target (cargo-triplet (or target system))) > (features ''()) > @@ -185,6 +188,7 @@ (define* (cargo-cross-build name > #:vendor-dir #$vendor-dir > #:cargo-build-flags #$(sexp->gexp cargo-build-flags) > #:cargo-test-flags #$(sexp->gexp cargo-test-flags) > + #:cargo-package-crates #$(sexp->gexp cargo-package-crates) > #:cargo-package-flags #$(sexp->gexp cargo-package-flags) > #:cargo-target #$(cargo-triplet (or target system)) > #:features #$(sexp->gexp features) > diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm > index 58238992b8..001e9c7adc 100644 > --- a/guix/build/cargo-build-system.scm > +++ b/guix/build/cargo-build-system.scm > @@ -300,11 +300,16 @@ (define* (package #:key > source > skip-build? > install-source? > + (cargo-package-crates '()) > (cargo-package-flags '("--no-metadata" "--no-verify")) > + (vendor-dir "guix-vendor") > #:allow-other-keys) > "Run 'cargo-package' for a given Cargo package." > (if install-source? > - (if skip-build? > + ;; NOTE: Cargo workspace packaging support: > + ;; #:install-source? #t + #:cargo-package-crates. > + (if (and (null? cargo-package-crates) > + skip-build?) > (begin > (install-file source "target/package") > (with-directory-excursion "target/package" > @@ -322,7 +327,26 @@ (define* (package #:key > ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source > (when (file-exists? "Cargo.toml.orig") > (delete-file "Cargo.toml.orig")) > - (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags)) > + > + (if (null? cargo-package-crates) > + (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags)) > + ;; Use unstable feature ‘--registry’. > + (begin > + (setenv "RUSTC_BOOTSTRAP" "1") > + (for-each > + (lambda (pkg) > + (apply invoke "cargo" "package" "--offline" "--package" pkg > + "--registry" "crates-io" "-Z" "package-workspace" > + cargo-package-flags) > + (for-each > + (lambda (crate) > + (invoke "tar" "xzf" crate "-C" vendor-dir)) > + (begin > + (delete-file-recursively "target/package/tmp-registry") > + (find-files "target/package" "\\.crate$"))) > + (patch-cargo-checksums #:vendor-dir vendor-dir)) > + cargo-package-crates) > + (unsetenv "RUSTC_BOOTSTRAP"))) > > ;; Then unpack the crate, reset the timestamp of all contained files, and > ;; repack them. This is necessary to ensure that they are reproducible. > -- > 2.48.1 > > >
Comments
On Tue, 18 Mar 2025 19:49:15 +0800, Efraim Flashner wrote: > > [1 <multipart/mixed (7bit)>] > [1.1 <text/plain; utf-8 (quoted-printable)>] > I've attached a diff that removes the need for RUSTC_BOOTSTRAP that > seems to work when I rebuilt rust-pubgrub. > > Some links I followed: > https://doc.rust-lang.org/cargo/commands/cargo-publish.html#package-selection > https://github.com/rust-lang/cargo/issues/10948#issuecomment-1229236664 > "One background knowledge: cargo publish is roughly `cargo package` + > call crates.io API." > > Before and after: > > (ins)efraim@3900XT ~/workspace/guix-rust-team$ tree /gnu/store/zk1n23l2wdca8snz1wqllmjxv83hccl5-rust-pubgrub-0.3.0-0.b70cf70 | head > /gnu/store/zk1n23l2wdca8snz1wqllmjxv83hccl5-rust-pubgrub-0.3.0-0.b70cf70 > └── share > ├── cargo > │ ├── registry > │ │ ├── pubgrub-0.3.0.crate > │ │ └── version-ranges-0.1.1.crate > │ └── src > │ ├── pubgrub-0.3.0 > │ │ ├── benches > │ │ │ ├── backtracking.rs > (ins)efraim@3900XT ~/workspace/guix-rust-team$ tree /gnu/store/9310sgn182cgqy4p1xkn2hi8x4wg0nn8-rust-pubgrub-0.3.0-0.b70cf70 | head > /gnu/store/9310sgn182cgqy4p1xkn2hi8x4wg0nn8-rust-pubgrub-0.3.0-0.b70cf70 > └── share > ├── cargo > │ ├── registry > │ │ ├── pubgrub-0.3.0.crate > │ │ └── version-ranges-0.1.1.crate > │ └── src > │ ├── pubgrub-0.3.0 > │ │ ├── benches > │ │ │ ├── backtracking.rs Thanks! It works for rust-pipewire too.
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index e0170d971f9..712e31a5206 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -352,23 +352,17 @@ (define* (package #:key (if (null? cargo-package-crates) (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags)) - ;; Use unstable feature ‘--registry’. (begin - (setenv "RUSTC_BOOTSTRAP" "1") (for-each (lambda (pkg) (apply invoke "cargo" "package" "--offline" "--package" pkg - "--registry" "crates-io" "-Z" "package-workspace" cargo-package-flags) (for-each (lambda (crate) (invoke "tar" "xzf" crate "-C" vendor-dir)) - (begin - (delete-file-recursively "target/package/tmp-registry") - (find-files "target/package" "\\.crate$"))) + (find-files "target/package" "\\.crate$")) (patch-cargo-checksums #:vendor-dir vendor-dir)) - cargo-package-crates) - (unsetenv "RUSTC_BOOTSTRAP"))) + cargo-package-crates))) ;; Then unpack the crate, reset the timestamp of all contained files, and ;; repack them. This is necessary to ensure that they are reproducible.