Skip to content
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

cxx-qt-build: Export .qmltypes and qmldir for use with external tooling #982

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

LeonMatthesKDAB
Copy link
Collaborator

This should improve support for qmllint and qmlls

Currently we get this ouput from qmllint after this change:

examples/qml_features/qml on  963-custom-cmake [$!?] took 1m10s
❯ qmllint-qt6 -i ../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/qmldir pages/PropertiesPage.qml
Warning: pages/PropertiesPage.qml: Warnings occurred while importing base modules: [import]
---
Warning: ../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:15:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:25:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:81:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:96:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:121:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:140:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:155:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:175:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:234:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:252:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:283:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:308:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:321:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:332:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:351:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:376:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes:407:37: Meta object revision and export version differ.
Revision 0 corresponds to version 0.0; it should be 1.0.
 [import]
Warning: Found deprecated dependency specifications in ../../../build/examples/qml_features/cxxqt/plugins/com_kdab_cxx_qt_demo/plugin.qmltypes.Specify dependencies in qmldir and use qmltyperegistrar to generate qmltypes files without dependencies. [import]
---

Warning: pages/PropertiesPage.qml:36:5: Cannot assign to default property of incompatible type [incompatible-type]
    RustProperties {

Depends on #978

ahayzen-kdab and others added 20 commits June 19, 2024 15:34
This allows us to get away without whole-archive in CMake by declaring
an OBJECT library instead.
Otherwise, Ninja will complain, as it needs **some** rule to build the
target, even if that rule does nothing.
This caused a build failure when not building a binary.
Linking the object file in shouldn't produce issues.
And don't redirect the first build output to /dev/null

This should allow us to see what exactly is failing in CI.
Otherwise the linker order doesn't work out and the linker cannot
resolve the qt_static_plugin_*** functions
It's much more concise than using File::create followed by write!
This can be used to e.g. register custom types, import plugins, declare
modules, etc.
This reverts commit 40f5ad1.

We are now building and linking object files directly, which works
nicely with CMake and seems to work for Rust as well.
This may be a clippy bug, as `cargo expand` tells me the generated
functions do indeed have a `# Safety` section in their documentation.

The `# Safety` sections also show up in the output of `cargo doc`.
So it's unclear why clippy is complaining.
This way we don't need a separate object file and CMake target for this.
@ahayzen-kdab
Copy link
Collaborator

For

Warning: pages/PropertiesPage.qml:36:5: Cannot assign to default property of incompatible type [incompatible-type]
    RustProperties {

we might need to change that code to be

readonly property RustProperties rustProperties: RustProperties {}

instead of

RustProperties {
  id: rustProperties
}

But there are likely other places that complain about this too.

For the other issues looks maybe related to missing setting a version in the plugin ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants