From patchwork Tue Mar 18 14:26:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40334 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 D8E2C27BBEA; Tue, 18 Mar 2025 14:30:18 +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=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,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 3FBCF27BBE2 for ; Tue, 18 Mar 2025 14:30:18 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXws-0005aa-1O; Tue, 18 Mar 2025 10:29:42 -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 ) id 1tuXwK-0005Eq-NG for guix-patches@gnu.org; Tue, 18 Mar 2025 10:29:14 -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 ) id 1tuXwJ-0001Sf-UL; Tue, 18 Mar 2025 10:29:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=MBzb7Ibac3SmOWIkI8ON7GjHlsaB/193XKHyjTRQoqk=; b=eNUFdsyWK9R2a6RLQ2Be2ida9+fd4Qg7cjemWN0pN5z2he8uOME0I2lMGyoYFd0YHUPL1TQrtZYtTDF1DQEGE3SKEEAPvZGHBwbDAlq2WQch4aLRyq7hD2RZUaLmkf9H7G3Xb50FGPHDmrssm87GBQoHK/lw3RCGNM5Q3VLYAGkV3/hT5LRASyiDWSr0iSX+kxZlyPhJq+pwMuh/X1yDGbKdVW+TgHVqeE106v+qh8Qdm4wQFeLwmeK7zuqgZKhwb+1k0BnNzTwx6tol4X42plITIoFtncf9btAoKBf/RVguMrd5rjw9w2mpeQuEjj2bfrEZiv5v50DndseLI2m09A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXwH-0004hc-3C; Tue, 18 Mar 2025 10:29:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 03/17] build-system: cargo: Support packaging Cargo workspace. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, ludo@gnu.org, maxim.cournoyer@gmail.com, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:29:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230810217673 (code B ref 77093); Tue, 18 Mar 2025 14:29:05 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:28:22 +0000 Received: from localhost ([127.0.0.1]:41688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXvY-0004ak-BU for submit@debbugs.gnu.org; Tue, 18 Mar 2025 10:28:22 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:41352) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuXum-0004Rg-OD for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:37 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742308051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MBzb7Ibac3SmOWIkI8ON7GjHlsaB/193XKHyjTRQoqk=; b=CAO3v5ls3poQIH4dEqgJb7w/xXCmbp02frI+NEooFoPefbxbQxiC7E1dEiTimkERBqP0hC NM5faMK0/9DZ+O9YAIsf85r/91MoMKxvKcZTlm/G3a7balkcL1kO5jQXYvWuzToTO41GBM hGOnLE87MiwaaRKP1Uo9hVRhoDN7reZ8NcTfeEjJ7YcVINH3VNlC5gRCXKJlnVQLNQqyCE AusZcUoaawHQ8BXL3+osscYigeSvDVKL5eRhQ3o2vZV9INCZooRXhsM91omvw/oVvwzboo /gSk/fDsPIBJDOPXg1Qo4fNstkNMcsnAtwEbw26+QCoSFcoEYQSqWCC/n8HbZA== Date: Tue, 18 Mar 2025 22:26:46 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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 | 22 ++++++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0ca109a214..0089f9e60f 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 the @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..979f93aef4 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,20 @@ (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)) + (begin + (for-each + (lambda (pkg) + (apply invoke "cargo" "package" "--offline" "--package" pkg + cargo-package-flags) + (for-each + (lambda (crate) + (invoke "tar" "xzf" crate "-C" vendor-dir)) + (find-files "target/package" "\\.crate$")) + (patch-cargo-checksums #:vendor-dir vendor-dir)) + 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.