mesonbuild / meson

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

BUG: Building a Rust crate from crates.io may fail #13321

Open Nautilus-1021 opened 2 months ago

Nautilus-1021 commented 2 months ago

Describe the bug I am trying to do do a project with Meson and Rust that requires some crates from crates.io to be compiled. I was amazed when I saw all the meson.build files generated from the normal rust crates. But there is a bug in the generation of the file, because if the crate specifies more that one type of crate to generate, Meson tries to override the dependency for each of the type of crate.

The bug is exactly here: mesonbuild/cargo/interpreter.py:727-731

To Reproduce The crate that failed for me is zune-jpeg. Here is the wrap file that I use: (The file is named zune-jpeg-rs.wrap)

[wrap-file]
directory = zune-jpeg-0.4.11
source_url = https://crates.io/api/v1/crates/zune-jpeg/0.4.11/download
source_filename = zune-jpeg-0.4.11.tar.gz
source_hash = ec866b44a2a1fd6133d363f073ca1b179f438f99e7e5bfb1e33f7181facfe448
method = cargo

system parameters Host & Target: Windows 11 Visual Studio Build Tools 2022 17.10.1 / MSVC 19.40.33811 Python 3.12.3 Meson 1.4.1 Ninja 1.11.1

Nautilus-1021 commented 2 months ago

To reproduce the bug you might also need that wrap file (named zune-core-rs.wrap)

[wrap-file]
directory = zune-core-0.4.12
source_url = https://crates.io/api/v1/crates/zune-core/0.4.12/download
source_filename = zune-core-0.4.12.tar.gz
source_hash = 3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a
method = cargo