Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bobbens opened this issue Oct 4, 2024 · 1 comment
Open

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

bobbens opened this issue Oct 4, 2024 · 1 comment

Comments

@bobbens
Copy link

bobbens commented Oct 4, 2024

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

  • native build
  • arch linux
  • Python 3.126
  • Meson 1.5.2
  • Ninja 1.12.1
@BrknRobot
Copy link

BrknRobot commented Oct 5, 2024

Digging around in meson a bit

It seems DependancyFallbackHolder._do_subproject() is passing the subproject name without version to interpreter.do_subproject

subp_name = self.subproject_name
varname = self.subproject_varname
func_kwargs.setdefault('version', [])
if 'default_options' in kwargs and isinstance(kwargs['default_options'], str):
func_kwargs['default_options'] = listify(kwargs['default_options'])
self.interpreter.do_subproject(subp_name, func_kwargs)

and the cargo interpreter is expecting the version number to be included when it splits the provided name.
# subp_name should be in the form "foo-0.1-rs"
package_name = subp_name.rsplit('-', 2)[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants