Skip to content

0.27.0: rules-qml (QML applications) on rules-qt - #66

Merged
speak-agent merged 16 commits into
mainfrom
feat/rules-qml
Nov 24, 2026
Merged

speak-agent merged 16 commits into
mainfrom
feat/rules-qml

Conversation

@speak-agent

@speak-agent speak-agent commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

What

rules-qml (mcpp.rules.qml): mcpp's first-class support for QML applications, as a build plugin that sits on rules-qt. A project states its QML modules in build.mcpp; the rule declares the chain qt_add_qml_module runs as actions, places Qt's own QML modules beside the program, and writes a qt.conf.

mcpp::rules::qml::options o;
o.qt.modules = { "Core", "Gui", "Qml", "Quick" };
mcpp::rules::qml::qml_module probe;
probe.uri = "Probe"; probe.root = "qml/Probe";
probe.sources = { "qml/Probe/**/*.qml", "qml/Probe/**/*.js" };
o.modules = { probe };
return mcpp::rules::qml::compile(o) ? 0 : 1;
  • The chain per module: moc --output-json → qmltyperegistrar (the SDK's and the other modules' type descriptions as foreign types, so a C++ type may derive from another module's) → qmlcachegen per file and its loader → rcc; qsb for shaders; qmllint as a check. Everything is a role = source action with declared inputs/outputs; the generated .cpp files are compiled into the executable, so a module is static and loadFromModule finds it.
  • Qt's own modules the program imports are found by reading the import statements and the SDK's qmldir/.qml files at plan time (the closure qmlimportscanner computes; equal to the scanner's on four samples), and placed under qml/ with deploy.
  • qt.conf (Prefix = ., Qml2Imports = qml), written by default, yielding to a project's own.
  • rules-qt, additive and off by default: moc_json, moc_includes, compile_ex, i18n.extensions.

The engine gap (mcpp#1011) was the engine's

mcpp pack computed the runtime closure from the program alone, so a plugin that deploy places beside it (libqxcb.so, libqquicklayoutsplugin.so) was packed without the libraries it loads (measured on qml-deploy: 40 libraries packed, none of libQt6QuickLayouts, libQt6QuickShapes, libQt6XcbQpa). mcpp 2026.11.23.1 (mcpp#1006) takes what the build deploys beside the program as a root of the closure, so this PR carries no workaround. CI pins that release (MCPP_VERSION, MCPP_BOOTSTRAP, MCPP_EDITOR_VERSION). The package floor stays 2026.10.30.1, as for 0.21.0's cross CMake lane: the build and rules-qt run on the older engine and only a pack that carries the plugins' libraries needs the new one, which README and docs/rules-qml.md state. Measured with the release on Linux: qml-deploy's packed tree holds all 1058 SDK dependencies of its files, and qt-widgets-consumer's has libQt6XcbQpa.so.6.

On macOS mcpp pack does not stage Qt's frameworks yet (the Widgets fixture of rules-qt does not pack there either), so the QML fixtures check qml/ and qt.conf in the directory the program is built into.

Tests

  • tests/plugin-logic: a golden of the 0.26 rules-qt directives that fails if any changes; every action of rules-qml, its generated qmldir/qrc text, input refusals, header ownership, the import closure with styles/imports/import_paths, qt.conf. 70 cases in all.
  • Fixtures: qml-consumer (C++ types, singletons, a script, a nested file, a resource, qsTr; AOT symbol check; an edit regenerates one unit and the resources and nothing else, by time stamp; variants noaot, styles, noconf), qml-modules, qml-deploy (compared with qmlimportscanner, packed-tree closure, packed program run with the SDK's directory renamed away), qml-import-only, qml-shaders (Linux; skips with a notice while the published qsb is the pre-xim-pkgindex#1262 one).
  • The new build programs are also in the llvm lane (--configure-only) and the editor lane; plugin-logic passes under LLVM 22.1.8 with libc++.

Toolchains follow rules-qt: Linux gcc with cxx_runtime = "toolchain-coupled", the engine's default elsewhere.

Verification

CI on 2be9a2b, all six jobs: rules (windows), rules (macos), consumers (linux), llvm (linux, libc++), editor, deps without Visual Studio (managed MSVC). The Windows and macOS code paths (qt.conf, -F and -I<sdk>/include for moc, the deployed qml/ tree, qmlimportscanner against the deployed modules) first ran there, and the two bugs they showed are fixed (QtQmlIntegration, header-only, is in <sdk>/include on macOS; Python and llvm-readobj write \r\n on Windows). No display was available on Linux, so the xcb plugin is checked by what the packed tree contains, not by a start; qml-shaders runs on Linux CI now that qsb starts.

A multi-perspective review of the diff reported ten items. Six are fixed: qsb missing left .qsb files in the resources; shader outputs could collide and their directory was not created; a plain QObject base header never reached the registrar; an empty SDK metatypes entry gave --foreign-types=,...; the import scanner lost line breaks in comments and ran an unterminated quote across lines; the Windows debug-twin rule hit a project's import_paths. Four are left on purpose: explicit headers are matched to moc units by the path string (the same route builds both, and the fixtures that list headers pass on all three platforms); header ownership is read from the text, so a QML macro in a comment counts (the refusal names the header and how to list it); one deploy per file, which costs plan time only; an empty i18n.extensions, which is what the project asked for.

Design and evidence: .agents/docs/2026-11-24-rules-qml-design.md and its spikes.

@speak-agent
speak-agent marked this pull request as draft November 23, 2026 20:03
@speak-agent speak-agent changed the title 0.27.0: rules-qml, mcpp.plugins.binary, and plugin_closure for rules-qt 0.27.0: rules-qml (QML applications) on rules-qt Nov 23, 2026
…sources, plain base classes reach the registrar, import scanning keeps line breaks); restore the qml plugin-logic cases the workaround removal dropped
…mlIntegration (header-only) lives; QtQml's own header includes it
…lt into; mcpp pack does not stage Qt's frameworks there yet
…s from the module lists; the shader check accepts the url a compiled component reports
@speak-agent
speak-agent marked this pull request as ready for review November 24, 2026 01:55
@speak-agent
speak-agent merged commit c874271 into main Nov 24, 2026
6 checks passed
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.

2 participants