Skip to content

meson: Fix compilation under Windows (MSVC), macOS, and Android

Amyspark requested to merge amyspark/librsvg:cerbero into main

Hi all,

Back when I implemented the mesonification of librsvg, I forced the installable target of rsvg-2 to be a shared library. This was because Meson and Rust, at link time, differ on the naming convention expected of static libraries:

https://github.com/rust-lang/rust/issues/122455

https://mesonbuild.com/FAQ.html#why-does-building-my-project-with-msvc-output-static-libraries-called-libfooa

I did not realise at the time that the fix merged in !938 (merged) (commit 73d71672) was not aware of this issue, and so it broke the Cerbero builds targeting Microsoft compilers. This commit works around the Rust bug by following the Linux convention for static libraries, and then using a custom target to rename the Rust-generated library if under MSVC.

All targets that depend on librsvg_lib do so now unconditionally, given they must link at a time where the file outputs are settled.

Additionally, I made fixes to the Cargo wrapper logic to match properly the output name of the PDB files (affecting rsvg-convert), and detection for llvm-nm which is required to parse Rust's object files under Darwin and Android platforms, and thus generate the shared library on those platforms.

This MR should be read in tandem with https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1444 where I am testing this. (There are deprecations that will still cause the builds to fail, those will be handled in https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6613.)

cc @sdroege @kleisauke @federico

Edited by Amyspark

Merge request reports