Open Be-ing opened 2 years ago
Related: #119
I assume you mean multiple crates ? And not multiple modules, as we support already defining multiple modules that are in the same crate and are then expose multiple QObject's to C++.
Are you describing having multiple Rust crates so that there would be two Rust static libraries to link to the C++ application ? As I don't really see why that wouldn't work already ? (or would there be collisions where some CXX things are the same in both the libs?) Once we have the CMake CLI tool it'll be easier to work with cargo workspaces too.
Create a cargo workspace within the application repository with multiple lib crates, built as normal rlib crates. Link them together into one staticlib crate and link the staticlib crate into the C++ application. This is the approach Firefox takes: https://hg.mozilla.org/mozilla-central/rev/841c2247f57d, https://bugzilla.mozilla.org/show_bug.cgi?id=1163224
Proof of concept of that is in #598. Unfortunately it is blocked on https://github.com/rust-lang/rust/issues/108081 upstream.
Application developers will likely want to link multiple cxx-qt modules into applications. I can think of two approaches this could take:
rlib
crates. Link them together into onestaticlib
crate and link thestaticlib
crate into the C++ application. This is the approach Firefox takes: https://hg.mozilla.org/mozilla-central/rev/841c2247f57d, https://bugzilla.mozilla.org/show_bug.cgi?id=1163224staticlib
crate with separate modules using cxx-qt within it. I doubt this would be a good idea for build times because Cargo parallelizes at the level of crates, not modules.