Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,9 @@ jobs:
- name: rules-qt runs moc, rcc, lupdate and lrelease, with the SDK the project declares
run: bash .github/scripts/check-deps-and-qt.sh qt-consumer

- name: rules-slint generates a component, its module, and runs it headless, with the SDK the project declares
run: bash tests/slint-consumer/check-slint.sh

# The payload carries QtGui's runtime closure (libdbus, fontconfig, xcb,
# ...), so a Widgets program links, runs offscreen and packs on Linux.
- name: rules-qt builds a Widgets program with a .ui form, runs it offscreen and packs it
Expand Down Expand Up @@ -2735,6 +2738,9 @@ jobs:
- name: rules-qt runs moc, rcc, lupdate and lrelease, with the SDK the project declares
run: bash .github/scripts/check-deps-and-qt.sh qt-consumer

- name: rules-slint generates a component, its module, and runs it headless, with the SDK the project declares
run: bash tests/slint-consumer/check-slint.sh

# Windows: the payload carries the VC++ runtime Qt's DLLs import, so the
# program starts on a machine without the VC++ Redistributable. macOS:
# Qt loads system frameworks only.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ mcpp 2026.11.7.1 or later; cross configuration requires CMake 3.19 or later.
| `rules-metal` | `mcpp.rules.metal` | 2026.9.8.1 | Compiles `.metal` shaders into Metal libraries with the host's Xcode and deploys them beside the program. | [rules](docs/rules.md#rules-metal) |
| `rules-qt` | `mcpp.rules.qt` | 2026.10.1.3 | Runs `moc`, `uic`, `rcc` and Qt's Linguist tools as actions, links the Qt modules and places their runtime. | [rules-qt](docs/rules-qt.md) |
| `rules-slang` | `mcpp.rules.slang` | 2026.10.1.3 | Compiles Slang (`*.slang`) and embeds or places the result. | [rules](docs/rules.md#rules-slang) |
| `rules-slint` | `mcpp.rules.slint` | 2026.10.1.3 | Compiles Slint user interfaces (`*.slint`) with `slint-compiler` into headers and, on request, C++ modules. | [rules-slint](docs/rules-slint.md) |
| `rules-spirv` | `mcpp.rules.spirv` | 2026.10.1.3 | Compiles GLSL and HLSL shader stages to SPIR-V and embeds or places the result. | [rules](docs/rules.md#rules-spirv) |
| `rules-swift` | `mcpp.rules.swift` | 2026.9.8.1 | Compiles a package's `.swift` sources into one module the C and C++ sources call. | [rules](docs/rules.md#rules-swift) |
| `rules-sycl` | `mcpp.rules.sycl` | 2026.10.1.3 | Compiles SYCL (`*.sycl`) with DPC++. | [rules](docs/rules.md#rules-sycl) |
Expand Down
1 change: 1 addition & 0 deletions docs/engine-and-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Each rule therefore selects the extensions it claims and leaves the rest:
| `rules-metal` | `.metal` |
| `rules-qt` | `.ui`, `.qrc`, `.ts`; a header is found by what it declares, since `.h` is already C++ |
| `rules-slang` | `.slang` |
| `rules-slint` | `.slint` |
| `rules-swift` | `.swift` |
| `rules-sycl` | `.sycl` |
| `rules-spirv` | `.comp .vert .frag .geom .tesc .tese .mesh .task .rgen .rint .rahit .rchit .rmiss .rcall`, and `.glsl` / `.hlsl` so that a stage-less name is refused by name rather than by absence |
Expand Down
78 changes: 78 additions & 0 deletions docs/rules-slint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# `rules-slint`

`mcpp.rules.slint` compiles [Slint](https://slint.dev) user interfaces: each `.slint` file becomes, through `slint-compiler`, a C++ header (and on request a number of `.cpp` units and a C++ module) the program uses. It is what upstream's CMake function `slint_target_sources` does. The rule declares no SDK and pins no version: the compiler and the runtime the program links come from one Slint SDK the project chooses. Module `mcpp.rules.slint`; engine floor 2026.10.1.3; from 0.27.0.

## Use

```toml
[build-dependencies.mcpp]
plugins = { version = "0.27.0", features = ["rules-slint"], host-module = true }

[dependencies]
mcpplibs.mwrap.slint = "1.19.0" # or compat.slint: the SDK as a package

[build]
sources = ["src/*.cpp", "ui/app.slint"]
```

```cpp
// build.mcpp
import mcpp.rules.slint;

int main() {
mcpp::rules::slint::options o;
o.module = "app.ui"; // also write `export module app.ui;`
return mcpp::rules::slint::compile(o) ? 0 : 1;
}
```

```cpp
// src/main.cpp
import app.ui; // or: #include "app.h"

int main() {
auto ui = AppWindow::create();
ui->run();
}
```

## Options and upstream CMake

| `slint_target_sources` / target property | option | `slint-compiler` |
|---|---|---|
| the `.slint` inputs | `[build] sources`, `options::sources` | the input |
| `NAMESPACE` | `ns` | `--cpp-namespace` |
| `LIBRARY_PATHS name=path` | `library_paths` | `-L name=path` |
| — | `include_paths` | `-I` |
| `COMPILATION_UNITS n` | `compilation_units` | `--cpp-file` × n, each compiled |
| `EDITION` | `edition` | `--edition` |
| `SLINT_STYLE` | `style` | `--style` |
| `SLINT_EMBED_RESOURCES` | `embed_resources` | `--embed-resources` |
| `SLINT_SCALE_FACTOR` | `scale_factor` | `--scale-factor` |
| `SLINT_TRANSLATION_DOMAIN` | `translation_domain` | `--translation-domain` |
| `SLINT_BUNDLE_TRANSLATIONS` | `bundle_translations` | `--bundle-translations` |

Each input is one action with the depfile `slint-compiler --depfile` writes, so an edit of the input or of a file it imports regenerates that input alone, and a build with nothing changed regenerates nothing. Two inputs with one stem are refused, since both would write `<stem>.h`.

## The module

With `options::module`, the rule writes a module interface unit per input (`module` for one input, `<module>.<stem>` for several): the generated header in its global module fragment and `export using` for what the input exports and `slint-compiler` generates, under the exported names:

- each exported component that inherits `Window` or `Dialog`, directly or through components of its own (`slint-compiler` generates nothing for an exported component that is not a window);
- each exported `struct`, `enum` and `global`;
- the aliases of `export { A as B }`, and what `export { … } from "…"` and `export * from "…"` re-export, read from the files they name (`library_paths` and `include_paths` resolve them; the built-in libraries such as `std-widgets.slint` export nothing of their own).

The rule reads the `.slint` files while the build program runs, so a change to their exports re-plans the build. `options::exports` names the exports instead, for a file the reading does not cover. The header is not included inside `export { … }`: Clang refuses to export the out-of-class member definitions `slint-compiler` writes.

## The SDK

The first that answers decides, recorded as the fact `rules-slint.sdk`:

| level | how |
|---|---|
| 1. build program | `options::compiler` (a tool choice: a path, `tool::on_path()`) or `options::root` (an SDK laid out as upstream's: `bin/`, `lib/`, `include/slint/`) |
| 2. environment | `SLINT_COMPILER`, the name of upstream CMake's cache variable |
| 3. a package of the graph | the directory of `compat.slint` (`options::sdk_package`), which the program depends on directly or through `mcpplibs.mwrap.slint` |
| 4. declared payload | `xim:slint`, at the version the project's `[xlings]` table states |

At levels 1 and 4 the SDK is not a package, so the rule puts it on the build: `include/slint` on the include path, `slint_cpp` on the link and its directory among the program's run-time directories (`lib`, or `bin` on Windows, where the DLL is placed beside the program). At level 3 the package does that itself. With none, the rule warns and plans nothing.
14 changes: 13 additions & 1 deletion mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "plugins"
namespace = "mcpp"
version = "0.26.1"
version = "0.27.0"
# The first mcpp release that speaks protocol 17 (SPEC-013, mcpp#847): the
# platform's directives `mcpp.plugins.platform` states (`link_driver`,
# `link_input`, `artifact_name`, `seal`, `run_host`), the `platform` phase, and
Expand Down Expand Up @@ -212,6 +212,18 @@ implies = ["plugins-core"]
rule_module = "mcpp.rules.qt"
device_extensions = [".ui", ".qrc", ".ts"]

# Slint's `.slint -> C++` (slint-compiler), what upstream CMake's
# `slint_target_sources` does: one action per input with its depfile, and on
# request a module interface unit exporting what the input exports. `.slint`
# files named in `[build] sources` reach the rule through
# `mcpp::device_sources()`. The SDK is the project's choice (docs/rules-slint.md):
# `compat.slint` in the graph, `xim:slint` in `[xlings]`, or an explicit one.
[features.rules-slint]
sources = ["rules/slint.cppm"]
implies = ["plugins-core"]
rule_module = "mcpp.rules.slint"
device_extensions = [".slint"]

# WHERE QT COMES FROM IS THE PROJECT'S CHOICE, not a feature: `rules-qt` finds
# the SDK from `options::root`, `QT_ROOT_DIR`, or a Qt payload the project
# declares in its own `[xlings]` table at the version it chooses
Expand Down
Loading
Loading