Bug 289659 - Mk/Uses/cargo.mk: Allow to build Rust subprojects
Summary: Mk/Uses/cargo.mk: Allow to build Rust subprojects
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Victorovich
URL:
Keywords:
Depends on:
Blocks: 289538
  Show dependency treegraph
 
Reported: 2025-09-17 06:14 UTC by Yuri Victorovich
Modified: 2025-09-23 06:54 UTC (History)
1 user (show)

See Also:


Attachments
patch (3.85 KB, patch)
2025-09-17 06:14 UTC, Yuri Victorovich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2025-09-17 06:14:30 UTC
Created attachment 263870 [details]
patch

Currently Mk/Uses/cargo.mk builds purely Rust ports.
The attached patch allows to build ports that are in other languages but that have Rust parts.

In short: Ports that build Rust subprojects would define CARGO_SRC_SUBDIR=path/to/rust/subproject. This adjusts paths where vendored crates are supplied (.cargo/config.toml). This also makes CARGO_BUILD, CARGO_INSTALL, CARGO_TEST to default to "no", because these would be invoked by the project. 

For an example please see the cad/librepcb patch in the dependent PR.
Comment 1 Mikael Urankar freebsd_committer freebsd_triage 2025-09-17 10:53:56 UTC
s/subdurectory/subdirectory/

Does it break existing port?
Feel free to commit it if there is no fallout.
Comment 2 Yuri Victorovich freebsd_committer freebsd_triage 2025-09-17 17:33:22 UTC
(In reply to Mikael Urankar from comment #1)

Thanks for a quick approval, Mikael.

I've built ~20 Rust ports and there doesn't seem to be any breakage.
Comment 3 Yuri Victorovich freebsd_committer freebsd_triage 2025-09-19 02:01:50 UTC
Committed.
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-09-19 02:02:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=310d28456b124865b43f95dfceed14942a70f622

commit 310d28456b124865b43f95dfceed14942a70f622
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2025-09-18 19:08:12 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2025-09-19 02:02:02 +0000

    Mk/Uses/cargo.mk: Allow to build Rust subprojects

    cargo-based ports can now set CARGO_SRC_SUBDIR=path/to/rust/subproject
    and it will be configured correctly.

    The build/install/test phases would be done by the enclosing project.

    PR:             289659
    Approved by:    mikael@ (on behalf of rust@)

 Mk/Uses/cargo.mk | 46 ++++++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 16 deletions(-)
Comment 5 Mikael Urankar freebsd_committer freebsd_triage 2025-09-20 08:02:01 UTC
It seems this patch breaks some ports (I don't have an exhaustive list:
devel/parol
devel/parol-ls
devel/py-qcs-sdk-python


error: failed to load manifest for workspace member `/wrkdirs/usr/ports/devel/parol/work/parol-1.0.1/crates/.cargo`
referenced via `crates/*` by workspace at `/wrkdirs/usr/ports/devel/parol/work/parol-1.0.1/Cargo.toml`

Caused by:
  failed to read `/wrkdirs/usr/ports/devel/parol/work/parol-1.0.1/crates/.cargo/Cargo.toml`

Caused by:
  No such file or directory (os error 2)
*** Error code 101


Something needs to be adjusted in such ports?
Comment 6 Yuri Victorovich freebsd_committer freebsd_triage 2025-09-20 09:31:19 UTC
(In reply to Mikael Urankar from comment #5)

Hi Mikael,

Thanks for reporting the failing ports.
This is caused by a quite special unanticipated condition.
I will fix these shortly.

There might be other ports like this.
Comment 7 commit-hook freebsd_committer freebsd_triage 2025-09-20 09:32:20 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4f8b9cbc02461fbcc38f91daa1764f3385e19221

commit 4f8b9cbc02461fbcc38f91daa1764f3385e19221
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2025-09-20 09:13:15 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2025-09-20 09:31:36 +0000

    devel/parol{,-ls}: Fix build by adjusting top-level Cargo.toml

    PR:             289659

 devel/parol-ls/Makefile                     |  8 +++++---
 devel/parol-ls/files/patch-Cargo.toml (new) | 13 +++++++++++++
 devel/parol/Makefile                        |  8 +++++---
 devel/parol/files/patch-Cargo.toml (new)    | 13 +++++++++++++
 4 files changed, 36 insertions(+), 6 deletions(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2025-09-20 09:44:22 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5b29ffd394cbe7b9b327c0b1b51e4576d928f067

commit 5b29ffd394cbe7b9b327c0b1b51e4576d928f067
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2025-09-20 09:43:32 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2025-09-20 09:44:13 +0000

    devel/py-qcs-sdk-python: Fix build by adjusting top-level Cargo.toml

    PR:             289659

 devel/py-qcs-sdk-python/Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Comment 9 Mikael Urankar freebsd_committer freebsd_triage 2025-09-23 06:54:03 UTC
(In reply to Yuri Victorovich from comment #6)
I couldn't find other ports with the same problem, closing.
Thanks for the quick fix.