-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build error when adding Rust integration tests to a cargo_without_cmake project #770
Comments
Interesting I can reproduce this as well. Wonder how this is supposed to work as we need the build script for the crate to work. Does it work if you move the tests into another crate and then depend on |
I've run it as well; in my setup, I don't have any integration tests depending on the bridge crate, but I happen to have both a I sort of got around my issue by hiding |
I can reproduce this as well. The issue is that the build.rs script compiles our generated C++ code and links it. This is the correct behavior to build the binary. As the integration test only builds the public interface, mod cxxqt_object; Which should fix However, I've noticed that this somehow causes issues with qrc... Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `/home/kdab/Documents/projects/3371-Rust-RnD/cxx-qt/target/debug/qml-minimal-no-cmake`
QQmlApplicationEngine failed to load component
qrc:/qt/qml/com/kdab/cxx_qt/demo/qml/main.qml: No such file or directory And the app doesn't load the window... That issue disappears when I remove the lib.rs file again. |
I wonder if this has something to do with a missing |
I created a repo with a repro: https://github.com/kristof-mattei/cxx-qt-lib-test As-is (with
which I traced to If you comment out
Now, if you remove |
https://github.com/kristof-mattei/cxx-qt-lib-test The |
@kristof-mattei Thank you for investigating this further and providing a workaround. @ahayzen-kdab We should try to integrate this into our build system, so that this happens automatically. |
@LeonMatthesKDAB the But there is a difference between runtime not finding the qml, which can be fixed with the import plugin hack I wrote, or the build error you get under certain conditions. I think certain code gets thrown away in the latter condition because we're not calling it. Which is why we need that call in the tests just to make sure the linker understands the components are needed. But that feels like a weird workaround. It's not Rust-like to have to do that. But I'm unsure how to tell the linker to retain stuff. |
Note that unused things being thrown away by the compiler we've hit before and was solved by putting those parts of the code into their own lib which are linked with |
It's more of a Cargo problem...
If you want to add Rust integration tests (a
tests/
dir alongside thesrc/
):then there is a linker error when running
cargo test
:Test itself (
integrationtest.rs
):The goal of the integration tests is to launch the
qml-minimal-no-cmake
binary, simulate inputs, examine outputs. No cxx-qt dependency needed.So the test build is somehow incompatible with the
build.rs
.Is there a way to make it just work by default without putting the tests in a separate crate?
The text was updated successfully, but these errors were encountered: