mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.65k stars 1.64k forks source link

rust: cargo wrap does not seem to like hyphens in project name #13754

Open bobbens opened 1 month ago

bobbens commented 1 month ago

Describe the bug When using a meson wrap around a Rust cargo file, it seems to internally chop the name at the first hyphen. In particular, the project quick-xml gets cut to quick at some point, and then it fails to find the Cargo.toml and fails to build. I have only seen this when the cargo package has a hyphen in its name.

To Reproduce The following wrap will fail to

[wrap-file]
method = cargo
directory = quick-xml-0.36.2
source_url = https://crates.io/api/v1/crates/quick-xml/0.36.2/download
source_filename = quick-xml-0.36.2.tar.gz
source_hash = f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe
[provide]
dependency_names = quick-xml-0.36.2-rs

will fail to compile when used as a wrap with dependency('quick-xml-0.36.2-rs') with:

Run-time dependency quick-xml-0.36.2-rs found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency quick-xml-0.36.2-rs

Executing subproject quick-xml-rs method cargo

../meson.build:351:18: ERROR: Cargo package 'quick' not found in subprojects/quick-xml-0.36.2

A full log can be found at /home/ess/naev/build/meson-logs/meson-log.txt
FAILED: build.ninja
/usr/bin/meson --internal regenerate /home/ess/naev .
ninja: error: rebuilding 'build.ninja': subcommand failed

I haven't been able to track it down, but somewhere, the package quick-xml is getting chopped to quick and then it is failing.

I have also tried with another project with a hyphen in the name grip-grab, and get a similar error, with the name getting truncated to grip in this case. My naive hypothesis is that some code to deal with -rs part of cargo wraps is truncating it, however, I have not looked further into it.

Expected behavior I would expect it to compile as a dependency without an issue.

system parameters

BrknRobot commented 1 month ago

Digging around in meson a bit

It seems DependancyFallbackHolder._do_subproject() is passing the subproject name without version to interpreter.do_subproject https://github.com/mesonbuild/meson/blob/9575ed30abba70508749d69a9f601e2c6ed657c2/mesonbuild/interpreter/dependencyfallbacks.py#L126-L131 and the cargo interpreter is expecting the version number to be included when it splits the provided name. https://github.com/mesonbuild/meson/blob/9575ed30abba70508749d69a9f601e2c6ed657c2/mesonbuild/cargo/interpreter.py#L711-L712

2xsaiko commented 4 days ago

This seems to be fixed in master.