From patchwork Mon Apr 28 16:23:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 42119 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 0F68627BC4B; Mon, 28 Apr 2025 17:34:17 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 68CBE27BC49 for ; Mon, 28 Apr 2025 17:34:16 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9RQJ-00085Q-Hb; Mon, 28 Apr 2025 12:33:41 -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 1u9RPG-0007f0-Ab for guix-patches@gnu.org; Mon, 28 Apr 2025 12:32:40 -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 1u9RP6-0004RK-GY; Mon, 28 Apr 2025 12:32:30 -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=xq8aZZS4z1iXsAw8Yh8ghtjt4KEmjBBBr2IR0G0tl30=; b=ULFktsQS2qfLuI6RC90ipl6CtApI7SHUmq0/Oro+kc4ux17Sk0sxyKEAsCCdtmoKsavwFEISIQxjETOIiDbPTlg64jPz94ecluysGp/1kSUM3XlUi31bsxrjuj+0oOhCLnHSxrkB81Cpq4C5bJ1gbiMJF6ZQpkeWy7R4qxSFBPEIo51cx/Z3tmkpRu3UVxjU+MVc+iHiqP573UZG6Oa2SwsntmYV6RzUZ1SzSp7KyKhi8QDe6BthMQC+y64B3qHul7hjfKQW2GctVZLQrN81dupQVWxvF+nPYX0E43EBhQNbFtVF8arbuozicLV/mL84laHJxx6TkHidFIgQTwze1Q==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u9ROw-0003JI-JS; Mon, 28 Apr 2025 12:32:14 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH v4 rust-team 09/22] build-system: cargo: Support packaging Cargo workspace. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, hako@ultrarare.space, ludo@gnu.org, maxim.cournoyer@gmail.com, steve@futurile.net, guix-patches@gnu.org Resent-Date: Mon, 28 Apr 2025 16:32:14 +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 , Divya Ranjan Pattanaik , Efraim Flashner , Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174585792012457 (code B ref 77093); Mon, 28 Apr 2025 16:32:14 +0000 Received: (at 77093) by debbugs.gnu.org; 28 Apr 2025 16:32:00 +0000 Received: from localhost ([127.0.0.1]:32857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u9ROh-0003Ek-6U for submit@debbugs.gnu.org; Mon, 28 Apr 2025 12:31:59 -0400 Received: from mail.boiledscript.com ([2a01:4f8:242:4aeb::42]:45812) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u9ROH-0003AD-1U for 77093@debbugs.gnu.org; Mon, 28 Apr 2025 12:31:37 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1745857891; 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=xq8aZZS4z1iXsAw8Yh8ghtjt4KEmjBBBr2IR0G0tl30=; b=gBHsRPV2Zdwhsb0gUcvb2FM7XunDh7NZD5jZ0vmJqn/Z4+x8cKhYji6CpbTmkDLB05Xc8Q nhoJSerSeLQ3AoWf9QldgKpKPnTz2GsiijLMyLi858cKU+c19/PhUz5iCTYFEjToiunnKe tF0UbNpjeQ6LmVyoRd2WGN/EvJP1Bkx4kdTHuU+8kjcx29rmfmuN/PqhhiIbEYKfw9Kjhy 4gXVZVTZAdJ+7Garqz/IaLL/zjAtLzlyOM3TYiak9byfQWt6jtS+ykD2rrXbb3fPtvdovR CBDqV03jb/5qZBcIinrZwGqgXRqAhqPwaafpnykhDP9lyBnKdzKzEkwR3acLbg== Date: Tue, 29 Apr 2025 00:23:06 +0800 Message-ID: <079eff3a62ed1319c6d8a0c3d84b244bf1479a2e.1745855744.git.hako@ultrarare.space> 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 | 21 +++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 7b418a4089..771547fafb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9493,6 +9493,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 f2ffc67879..2c47c1feaf 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -98,6 +98,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) @@ -126,6 +127,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) @@ -158,6 +160,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 ''()) @@ -189,6 +192,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 c37fd70418..85745d4d91 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -302,11 +302,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" @@ -324,7 +329,19 @@ (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)) + (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.