Skip to content

meson: support rust cross-compiling with cargo wrapper

Right now, the meson cargo wrapper does not attempt to use any of the meson rust cross settings (even though it does require them for the declared "rust" compiler in meson to not error out on cross -- it also ignores the native settings)

These changes attempt to extract the rust compiler cross info from meson and pass them along to cargo_wrapper.py to allow meson cross to work with gst-plugins-rs (right now I think cross is only done on gst-plugins-rs with Cerebro which uses cargo-c directly)

I made a few other drive-by fixes for this MR (extra_args = -> extra_args +=, build_machine -> host_machine) and had to have cargo_wrapper.py hoist out the --target flag because cargo-c needs to be aware of that flag (and it can't be slipped in through RUSTFLAGS) (also since this uses RUSTFLAGS for clarity instead of CARGO_ENCODED_RUSTFLAGS, complicated flags can't be used, but I don't think I've ever actually had rustc flags that needed escaped whitespace in them tbh so it shouldn't be a realistic problem)

Let me know if there's a better approach for making cargo_wrapper.py more meson-aware. I really don't know meson very well, but for meson rust cross it seems to only expect the required rustc command in cross-file.conf (so I only extracted the compiler's cmd_array()):

[binaries]
rust = [ 'rustc', '--target', 'aarch64-unknown-linux-gnu' ]

I can confirm that cross x86_64-linux -> aarch64-linux and native builds (x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin) all work with this change when building from meson


Side note, but I think this is the last change for getting these into nixpkgs! Thank you all for this lovely gstreamer plugin set! 😄

Merge request reports

Loading