Projects with rust code should not mix meson and Cargo building

Calling Cargo in meson.build seems counter intuitive. it would be better if build.rs is used instead as it can also run arbitrary commands and is baked into cargo, or use rustmod. it also helps distro packages as it is less convoluted to package projects using 1 build system than 2. remember that us packages cannot acess the internet when a build is running, and this cant fretch stuff from the inter net as and wehn we like

Please, never use build.rs for anything.

Cargo is not a tool useful for anything related to building and installing GUI applications; it’s barely enough for CLI tools. The only thing that Cargo really supports is building Rust modules.

In theory, Meson should take over the download and build of Rust crates in the future, but the mechanism is still experimental and kind of clunky.

Using build.rs does not solve the problems that are solved by an actual build system, like installing ancillary files like desktop entries, help, and other assets; it also does not solve the issue of calling other binaries at installation time. Cargo has no mechanism for that.

Distributions are perfectly capable of dealing with Meson/Cargo mixed builds. If your distro does not support this, please: file an issue in your distribution’s issue tracker, instead of complaining here.

Applications mixing Meson and Cargo should already vendor their dependencies—especially if they want to build on Flathub, as that environment also does not allow networked builds. If an application requires a networked build, please open an issue against that application.

2 Likes