Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
- name: Tests, release profile
run: mcpp test --profile release

- name: mcpp.plugins.slint generates a component, its module, and runs it headless with the SDK the project declares
- name: slint.mcpp.plugins generates a component, its module, and runs it headless with the SDK the project declares
run: MCPP="$(command -v mcpp)" bash tests/rule-consumer/check-slint.sh

- name: Export audit (the generated surface is fresh; every public name, key code and feature of the SDK's headers)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The upstream API is unchanged: `slint::ComponentHandle`, `slint::SharedString`,
`slint::VectorModel`, `slint::interpreter::ComponentCompiler` are the names of
`<slint.h>`. The SDK is `compat.slint` 1.19.0 (xim:slint: `libslint_cpp`, its
headers and `slint-compiler`, built from the release tag with upstream CMake's
default features). A `.slint` file is compiled by `mcpp.plugins.slint` (package
default features). A `.slint` file is compiled by `slint.mcpp.plugins` (package
`mcpplibs.slintgen`, in `rules/` of this repository), which the project's `build.mcpp`
imports; with `module` set, each file becomes a module the program imports.

Expand All @@ -23,7 +23,7 @@ imports; with `module` set, each file becomes a module the program imports.
- `import mcpplibs.mwrap.slint.interpreter;`: `slint::interpreter` -- `.slint` sources loaded at run time
- `import mcpplibs.mwrap.slint.platform;`: `slint::platform` -- a custom platform, the software renderer (Clang; with GCC include `<slint-platform.h>`)
- `import mcpplibs.mwrap.slint.macros;`: `SLINT_FEATURE_*` as `constexpr bool` in `mcpplibs::mwrap::slint::macros`
- `import app.ui;`: a component of yours, from `ui/app.slint` (`mcpp.plugins.slint`, `options::module`)
- `import app.ui;`: a component of yours, from `ui/app.slint` (`slint.mcpp.plugins`, `options::module`)

> More Modules API -> [Usage and API](docs/usage.md)

Expand All @@ -40,10 +40,10 @@ The default template opens a window with a counter; without a display (or with

```toml
[dependencies]
mcpplibs.mwrap.slint = "1.19.0"
mcpplibs.mwrap.slint = "1.19.0.1"

[build-dependencies]
mcpplibs.slintgen = { version = "1.19.0", features = ["slint"] } # claims `.slint`
mcpplibs.slintgen = { version = "1.19.0.1", features = ["slint"] } # claims `.slint`

[build]
sources = ["src/*.cpp", "ui/app.slint"]
Expand All @@ -52,7 +52,7 @@ sources = ["src/*.cpp", "ui/app.slint"]
```cpp
// build.mcpp
import mcpp;
import mcpp.plugins.slint;
import slint.mcpp.plugins;
int main() {
mcpp::plugins::slint::options o;
o.module = "app.ui";
Expand Down Expand Up @@ -90,7 +90,7 @@ the runtime types through the module, and a component compiled at run time by
export audit ([tools/check_exports.py](tools/check_exports.py)) reads clang's AST of
the SDK's headers: every public name exported, the key codes and features mapped,
the SDK's features upstream CMake's defaults. A separate job scaffolds the default
template as an installed package, builds it with `mcpp.plugins.slint` and runs it
template as an installed package, builds it with `slint.mcpp.plugins` and runs it
headless.

## License
Expand Down
12 changes: 6 additions & 6 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
上游 API 保持不变:`slint::ComponentHandle`、`slint::SharedString`、`slint::VectorModel`、
`slint::interpreter::ComponentCompiler` 就是 `<slint.h>` 里的名字。SDK 是 `compat.slint`
1.19.0(xim:slint:`libslint_cpp`、头文件和 `slint-compiler`,由发布 tag 按上游 CMake
默认功能构建)。`.slint` 文件由 `mcpp.plugins.slint`(包 `mcpplibs.slintgen`,在本仓库的 `rules/`)编译,
默认功能构建)。`.slint` 文件由 `slint.mcpp.plugins`(包 `mcpplibs.slintgen`,在本仓库的 `rules/`)编译,
由工程的 `build.mcpp` 导入;设置 `module` 后,每个文件都成为程序可以 import 的模块。

## 模块
Expand All @@ -21,7 +21,7 @@
- `import mcpplibs.mwrap.slint.interpreter;`:`slint::interpreter`,运行时加载 `.slint` 源码
- `import mcpplibs.mwrap.slint.platform;`:`slint::platform`,自定义平台与软件渲染器(Clang;GCC 下请 include `<slint-platform.h>`)
- `import mcpplibs.mwrap.slint.macros;`:`SLINT_FEATURE_*` 映射为 `constexpr bool`,位于 `mcpplibs::mwrap::slint::macros`
- `import app.ui;`:你自己的组件,来自 `ui/app.slint`(`mcpp.plugins.slint` 的 `options::module`)
- `import app.ui;`:你自己的组件,来自 `ui/app.slint`(`slint.mcpp.plugins` 的 `options::module`)

> 更多模块 API -> [用法和 API](docs/usage.md)

Expand All @@ -38,10 +38,10 @@ mcpp run

```toml
[dependencies]
mcpplibs.mwrap.slint = "1.19.0"
mcpplibs.mwrap.slint = "1.19.0.1"

[build-dependencies]
mcpplibs.slintgen = { version = "1.19.0", features = ["slint"] } # 认领 `.slint`
mcpplibs.slintgen = { version = "1.19.0.1", features = ["slint"] } # 认领 `.slint`

[build]
sources = ["src/*.cpp", "ui/app.slint"]
Expand All @@ -50,7 +50,7 @@ sources = ["src/*.cpp", "ui/app.slint"]
```cpp
// build.mcpp
import mcpp;
import mcpp.plugins.slint;
import slint.mcpp.plugins;
int main() {
mcpp::plugins::slint::options o;
o.module = "app.ui";
Expand Down Expand Up @@ -84,7 +84,7 @@ Linux、macOS 与 Windows 的 CI 用 GCC 和 Clang 构建模块并运行测试
以及由 `slint::interpreter` 在运行时编译组件、在无头平台上通过属性和回调驱动它。导出审计
([tools/check_exports.py](tools/check_exports.py))读取 SDK 头文件的 clang AST:每个公开名字都已导出,
按键码与功能都已映射,SDK 的功能即上游 CMake 默认值。另有一个任务把默认模板当作已安装包生成项目,
经 `mcpp.plugins.slint` 构建并无头运行。
经 `slint.mcpp.plugins` 构建并无头运行。

## 许可

Expand Down
14 changes: 7 additions & 7 deletions docs/rules.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# `mcpp.plugins.slint`
# `slint.mcpp.plugins`

`mcpp.plugins.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. Package `mcpplibs.slintgen` (`rules/` of this repository), module `mcpp.plugins.slint`; engine floor 2026.10.1.3.
`slint.mcpp.plugins` 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. Package `mcpplibs.slintgen` (`rules/` of this repository), module `slint.mcpp.plugins`; engine floor 2026.10.1.3.

## Use

```toml
[build-dependencies]
mcpplibs.slintgen = { version = "1.19.0", features = ["slint"] }
mcpplibs.slintgen = { version = "1.19.0.1", features = ["slint"] }

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

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

The project names the feature itself: `.slint` becomes a source the rule claims through the feature (`device_extensions`), and a claim made by a package another package re-exports does not reach the project. The module name `mcpp.plugins.slint` is the maintainers' choice; SPEC-007 R9.6 keeps `mcpp.plugins.*` for the mcpp project's namespace, so the engine prints one warning per build that a package outside it provides the module ("Nothing breaks").
The project names the feature itself: `.slint` becomes a source the rule claims through the feature (`device_extensions`), and a claim made by a package another package re-exports does not reach the project. The module is named `slint.mcpp.plugins`, under the library's name: SPEC-007 R9.6 keeps `mcpp.plugins.*` for the mcpp project's namespace. Its C++ namespace is `mcpp::plugins::slint`, beside the engine's `mcpp::plugins`.

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

int main() {
mcpp::plugins::slint::options o;
Expand Down Expand Up @@ -68,7 +68,7 @@ The rule reads the `.slint` files while the build program runs, so a change to t

## The SDK

The first that answers decides, recorded as the fact `mcpp.plugins.slint.sdk`:
The first that answers decides, recorded as the fact `slint.mcpp.plugins.sdk`:

| level | how |
|---|---|
Expand Down
2 changes: 1 addition & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import mcpplibs.mwrap.slint;

## Components from `.slint` files

`mcpp.plugins.slint` (package `mcpplibs.slintgen`, `rules/` of this repository; declared in `[build-dependencies]` with `features = ["slint"]`, which also makes `.slint` a source the rule claims, and compat.slint re-exports `slint-compiler`) runs `slint-compiler` on each `.slint` file of `[build] sources`: one action per file, regenerated when the file or one it imports changes. Its options are upstream CMake's `slint_target_sources` and target properties (`ns`, `library_paths`, `compilation_units`, `edition`, `style`, `embed_resources`, `scale_factor`, `translation_domain`, `bundle_translations`); with `module = "app.ui"` each file also becomes a module exporting its windows, structs, enums and globals. See [rules.md](rules.md).
`slint.mcpp.plugins` (package `mcpplibs.slintgen`, `rules/` of this repository; declared in `[build-dependencies]` with `features = ["slint"]`, which also makes `.slint` a source the rule claims, and compat.slint re-exports `slint-compiler`) runs `slint-compiler` on each `.slint` file of `[build] sources`: one action per file, regenerated when the file or one it imports changes. Its options are upstream CMake's `slint_target_sources` and target properties (`ns`, `library_paths`, `compilation_units`, `edition`, `style`, `embed_resources`, `scale_factor`, `translation_domain`, `bundle_translations`); with `module = "app.ui"` each file also becomes a module exporting its windows, structs, enums and globals. See [rules.md](rules.md).

## The SDK's features

Expand Down
6 changes: 3 additions & 3 deletions mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
[package]
namespace = "mcpplibs.mwrap"
name = "slint"
version = "1.19.0"
description = "Slint 1.19.0 C++ modules for mcpp (import mcpplibs.mwrap.slint;): the runtime API, the interpreter and the platform API over compat.slint, the features as constants; .slint files compile with mcpp.plugins.slint"
version = "1.19.0.1"
description = "Slint 1.19.0 C++ modules for mcpp (import mcpplibs.mwrap.slint;): the runtime API, the interpreter and the platform API over compat.slint, the features as constants; .slint files compile with slint.mcpp.plugins"
license = "Apache-2.0"
authors = ["mcpp-community"]
repo = "https://github.com/mcpplibs/slint-m"
Expand All @@ -20,7 +20,7 @@ include_dirs = ["include"]
[dependencies]
# The SDK: libslint_cpp, its headers and slint-compiler. Re-exported, so a
# consumer's build program finds slint-compiler in it (the rule
# mcpp.plugins.slint, package mcpplibs.slintgen, is rules/ of this repository).
# slint.mcpp.plugins, package mcpplibs.slintgen, is rules/ of this repository).
compat.slint = { version = "1.19.0", reexport = true }

[package.metadata.mwrap]
Expand Down
18 changes: 9 additions & 9 deletions rules/mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# slintgen — how a `.slint` file becomes part of a C++ program, as a package.
#
# The module is `mcpp.plugins.slint` (rules/src/slint.cppm). A consumer's
# The module is `slint.mcpp.plugins` (rules/src/slint.cppm). A consumer's
# build.mcpp imports it:
#
# import mcpp;
# import mcpp.plugins.slint;
# import slint.mcpp.plugins;
# int main() { return mcpp::plugins::slint::compile({}) ? 0 : 1; }
#
# It lives here, beside the modules whose Slint SDK it drives, as grpcgen lives
# in grpc-m: mcpp-plugins holds the rules that are not tied to one library's
# release, this repository the one that is. SPEC-007 R9.6 keeps `mcpp.plugins.*`
# for the mcpp project's own namespace, so the engine warns once per build that
# a package outside it provides this module; the name is the maintainer's
# choice and the warning is its price.
# release, this repository the one that is. The module is named under the
# library's own name (`slint.mcpp.plugins`), not under `mcpp.`: SPEC-007 R9.6
# keeps `mcpp.plugins.*` for the mcpp project's namespace, and the index admits
# no package that provides such a module.
#
# Versioned with slint-m (and so with the Slint it is built against).
[package]
name = "slintgen"
version = "1.19.0"
version = "1.19.0.1"
standard = "c++23"
description = "slint-compiler as an importable mcpp build rule (module mcpp.plugins.slint)"
description = "slint-compiler as an importable mcpp build rule (module slint.mcpp.plugins)"
license = "Apache-2.0"
repo = "https://github.com/mcpplibs/slint-m"
platforms = ["linux", "macos", "windows"]
Expand All @@ -38,7 +38,7 @@ default = []

[features.slint]
sources = ["src/slint.cppm"]
rule_module = "mcpp.plugins.slint"
rule_module = "slint.mcpp.plugins"
device_extensions = [".slint"]

[targets.slintgen]
Expand Down
16 changes: 8 additions & 8 deletions rules/src/slint.cppm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// mcpp.plugins.slint -- how a `.slint` file becomes part of a C++ program.
// slint.mcpp.plugins -- how a `.slint` file becomes part of a C++ program.
//
// Slint describes a user interface in its own language; `slint-compiler`
// turns each `.slint` file into a C++ header (and, with
Expand Down Expand Up @@ -32,7 +32,7 @@
// not enough.
//
// WHERE SLINT COMES FROM IS THE PROJECT'S CHOICE, in this order; the first
// that answers decides, and `mcpp::fact("mcpp.plugins.slint.sdk", …)` records it:
// that answers decides, and `mcpp::fact("slint.mcpp.plugins.sdk", …)` records it:
//
// 1. `options::compiler` / `options::root` in the build program;
// 2. the environment variable `SLINT_COMPILER` (upstream CMake's cache
Expand All @@ -51,7 +51,7 @@
// A MISSING SDK IS A WARNING. `mcpp emit build-database` plans a project on
// machines that never built it; the rule says what it could not find and
// declares nothing, so the plan succeeds and the build is where it fails.
export module mcpp.plugins.slint;
export module slint.mcpp.plugins;

import std;
import mcpp;
Expand Down Expand Up @@ -320,7 +320,7 @@ inline sdk locate(const options& opt) {
sdk out;
const std::string exe = is_windows() ? "slint-compiler.exe" : "slint-compiler";
if (!opt.compiler.is_default() || !opt.root.empty()) {
tool::spec s{.who = "mcpp.plugins.slint", .ns = "xim", .package = "slint",
tool::spec s{.who = "slint.mcpp.plugins", .ns = "xim", .package = "slint",
.programs = {"slint-compiler"}, .bin_dirs = {"bin", ""},
.option = "options::compiler", .legacy_env = "", .request = false};
auto f = tool::resolve(s, opt.root.empty() ? opt.compiler : tool::root(opt.root));
Expand All @@ -336,7 +336,7 @@ inline sdk locate(const options& opt) {
if (it->path().filename() == exe && it->path().parent_path().filename() == "bin")
return {generic(it->path()), {}, opt.sdk_package};
}
tool::spec s{.who = "mcpp.plugins.slint", .ns = "xim", .package = "slint",
tool::spec s{.who = "slint.mcpp.plugins", .ns = "xim", .package = "slint",
.programs = {"slint-compiler"}, .bin_dirs = {"bin"},
.option = "options::compiler", .legacy_env = "", .request = false};
if (auto f = tool::resolve(s); f) return {f.program, f.root, "xim:slint"};
Expand All @@ -348,7 +348,7 @@ inline sdk locate(const options& opt) {
inline bool compile(options opt = {}) {
namespace fs = std::filesystem;
using detail::generic;
const char* who = "mcpp.plugins.slint";
const char* who = "slint.mcpp.plugins";
mcpp::fact("mcpp.plugins", std::string(mcpp::plugins::version).c_str());

std::vector<std::string> inputs = detail::device_slint();
Expand All @@ -363,7 +363,7 @@ inline bool compile(options opt = {}) {
"name it with options::compiler. Nothing is generated.", who, inputs.size()));
return true;
}
mcpp::fact("mcpp.plugins.slint.sdk", std::format("{}: {}", sdk.level, sdk.compiler).c_str());
mcpp::fact("slint.mcpp.plugins.sdk", std::format("{}: {}", sdk.level, sdk.compiler).c_str());

// An SDK that is not a package of the graph: its headers, library and
// run-time directory are the rule's to put on the build.
Expand Down Expand Up @@ -433,7 +433,7 @@ inline bool compile(options opt = {}) {
for (auto const& r : read) mcpp::rerun_if_changed(generic(r).c_str());
const std::string module = files.size() == 1 ? opt.module : opt.module + "." + stem;
std::string unit = std::format(
"// Generated by mcpp.plugins.slint from {} -- do not edit.\n"
"// Generated by slint.mcpp.plugins from {} -- do not edit.\n"
"module;\n#include <array>\n#include <limits>\n#include <slint.h>\n#include \"{}.h\"\n\n"
"export module {};\n\n", f.filename().string(), stem, module);
if (opt.ns.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/slint.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// properties' types (SharedString, SharedVector, Color, Brush, Image …), models,
// timers and the event loop, and slint::language. The names are upstream's;
// the library is compat.slint's libslint_cpp. A component compiled from a
// `.slint` file (mcpp.plugins.slint) is used beside this module.
// `.slint` file (slint.mcpp.plugins) is used beside this module.
module;
#include <slint.h>

Expand Down
4 changes: 2 additions & 2 deletions templates/hello/build.mcpp.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ui/app.slint -> app.h and `export module app.ui;` (mcpp.plugins.slint, which
// ui/app.slint -> app.h and `export module app.ui;` (slint.mcpp.plugins, which
// package mcpplibs.slintgen runs on the SDK compat.slint provides).
import mcpp;
import mcpp.plugins.slint;
import slint.mcpp.plugins;

int main() {
mcpp::plugins::slint::options o;
Expand Down
2 changes: 1 addition & 1 deletion templates/hello/mcpp.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ kind = "bin"
main = "src/main.cpp"

[build]
# ui/app.slint reaches mcpp.plugins.slint, which writes app.h and the module app.ui.
# ui/app.slint reaches slint.mcpp.plugins, which writes app.h and the module app.ui.
sources = ["src/*.cpp", "ui/app.slint"]

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion templates/hello/src/main.cpp.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// {{project.name}} -- a Slint window: ui/app.slint is compiled into the module
// app.ui (mcpp.plugins.slint), the counter lives in C++.
// app.ui (slint.mcpp.plugins), the counter lives in C++.
//
// Without a display (Linux with neither DISPLAY nor WAYLAND_DISPLAY, or
// SLINT_HEADLESS=1) the program uses Slint's software renderer behind a
Expand Down
2 changes: 1 addition & 1 deletion templates/hello/template.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[template]
description = "A Slint window with import mcpplibs.mwrap.slint: ui/app.slint compiled by mcpp.plugins.slint into the module app.ui, a counter driven from C++"
description = "A Slint window with import mcpplibs.mwrap.slint: ui/app.slint compiled by slint.mcpp.plugins into the module app.ui, a counter driven from C++"
default = true
post_message = "Run `mcpp run`: a window with a counter. Without a display (or with SLINT_HEADLESS=1) it runs on Slint's software renderer and prints the counter."
2 changes: 1 addition & 1 deletion tests/rule-consumer/build.mcpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// exports what ui/app.slint exports and slint-compiler generates.
import std;
import mcpp;
import mcpp.plugins.slint;
import slint.mcpp.plugins;

int main() {
mcpp::plugins::slint::options o;
Expand Down
2 changes: 1 addition & 1 deletion tests/rule-consumer/check-slint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# mcpp.plugins.slint end to end: the fixture builds with the SDK the project declares
# slint.mcpp.plugins end to end: the fixture builds with the SDK the project declares
# (xim:slint), runs headless, and the rule's actions behave as one per input:
# the module exports what the input exports, an edit of a file the input
# imports regenerates it, a build with nothing changed regenerates nothing.
Expand Down
4 changes: 2 additions & 2 deletions tests/rule-consumer/mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fixture: a Slint user interface compiled by mcpp.plugins.slint, run headless.
# Fixture: a Slint user interface compiled by slint.mcpp.plugins, run headless.
#
# ui/app.slint a window (through a base component), a struct, an
# enum, a global, a non-window export (no code), and a
Expand All @@ -11,7 +11,7 @@
[package]
name = "slint-consumer"
version = "0.1.0"
description = "Fixture: a Slint UI built through mcpp.plugins.slint"
description = "Fixture: a Slint UI built through slint.mcpp.plugins"
license = "Apache-2.0"
authors = ["mcpp-community"]

Expand Down
Loading
Loading