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
23 changes: 12 additions & 11 deletions .agents/docs/2026-11-20-add-slint-mwrap-plan.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 实施方案:Slint 进入 mcpp 生态(compat.slint + mcpplibs.mwrap.slint + 构建规则 mcpp.plugins.slint)
# 实施方案:Slint 进入 mcpp 生态(compat.slint + mcpplibs.mwrap.slint + 构建规则 slint.mcpp.plugins)

状态:已按维护者决定修订(2026-11-20):规则放入 slint-m,模块名 `mcpp.plugins.slint`。上游版本:Slint 1.19.0(2026-11-16)。
状态:已按维护者决定修订(2026-11-20):规则放入 slint-m,模块名 `slint.mcpp.plugins`(`slint.mcpp.plugins` 被索引的 R9.6 收录门拒绝,见 §1 修订记录)。上游版本:Slint 1.19.0(2026-11-16)。
本文的事实均为实测或读源码所得,出处写在各条之后;未验证的部分列在 §9。

## 0. 目标
Expand All @@ -11,7 +11,7 @@
|---|---|
| `find_package(Slint)` + 预构建 SDK | `compat.slint` 的预构建档位(xlings-res,GitHub + GitCode) |
| `FetchContent(... SOURCE_SUBDIR api/cpp)` + `SLINT_FEATURE_*` | `compat.slint` 的同名 feature;未预构建的组合走源码构建(cargo,§4.3) |
| `slint_target_sources(...)` 与目标属性 | 构建规则 `mcpp.plugins.slint`(包 `mcpplibs.slintgen`,slint-m 的 `rules/`,§5) |
| `slint_target_sources(...)` 与目标属性 | 构建规则 `slint.mcpp.plugins`(包 `mcpplibs.slintgen`,slint-m 的 `rules/`,§5) |
| `#include "app.h"` | 同上,另可 `import` 生成的组件模块(§5.3) |
| — | `import mcpplibs.mwrap.slint;`(§6) |

Expand All @@ -21,12 +21,13 @@
|---|---|---|
| 上游库原样构建 | `compat.<名>` | `compat.slint` |
| 通用 C++ 库的模块封装 | `mcpplibs.mwrap.<名>`(docs/mwrap.md) | `mcpplibs.mwrap.slint`,仓库 `mcpplibs/slint-m` |
| mcpp 专用构建插件(导入引擎接口 `mcpp`) | 通常 `mcpp.<命名空间>.*`(R9.6);保留的第二段只属于命名空间为 `mcpp` 的包 | 包 `mcpplibs.slintgen`(slint-m 的 `rules/`,与 grpc-m 的 `grpcgen` 同形),模块 `mcpp.plugins.slint` |
| mcpp 专用构建插件(导入引擎接口 `mcpp`) | 通常 `mcpp.<命名空间>.*`(R9.6);保留的第二段只属于命名空间为 `mcpp` 的包 | 包 `mcpplibs.slintgen`(slint-m 的 `rules/`,与 grpc-m 的 `grpcgen` 同形),模块 `slint.mcpp.plugins` |

**修订记录。** 初版把规则放进官方插件包 `mcpp.plugins`(feature `rules-slint`,模块 `mcpp.rules.slint`),依据是 `rules-qt`
等先例与 R9.6。维护者决定改为放入 slint-m、模块名 `mcpp.plugins.slint`(mcpp-plugins#64 已不合入关闭)。代价已核实:
(1) 引擎对每次构建打印一条警告——`mcpp.plugins.slint` 由命名空间不是 `mcpp` 的包提供(R9.6,"Nothing breaks";
警告建议 `mcpp.mcpplibs.*`);(2) `device_extensions` 的认领不经 `reexport` 传递,所以工程须自己在
等先例与 R9.6。维护者决定改为放入 slint-m、模块名 `slint.mcpp.plugins`(mcpp-plugins#64 已不合入关闭)。代价已核实:
(1) 实测:`mcpp.plugins.slint` 由命名空间不是 `mcpp` 的包提供,引擎每次构建警告,而索引的成员门(tests/run_members.sh)
拒绝此类包,mcpp-index#861 因此失败;维护者改定模块名为 `slint.mcpp.plugins`(不以 `mcpp.` 起头,不受 R9.6 约束),
以修订号 1.19.0.1 发布(mwrap-1.19.0 已打标签、未收录);(2) `device_extensions` 的认领不经 `reexport` 传递,所以工程须自己在
`[build-dependencies]` 写 `mcpplibs.slintgen = { …, features = ["slint"] }`,slint-m 不再 reexport 规则;
(3) 规则对 `mcpp.plugins`(feature `plugins-core`)的依赖写在规则包自己的 `[dependencies]`(mcpp 2026.10.11.1+ 形态)。

Expand Down Expand Up @@ -75,7 +76,7 @@ xlings-res(GitHub + GitCode)
slint-vendor/<ver>/slint-<ver>-vendor.tar.zst cargo vendor(源码构建离线依赖)
skia-binaries/<key>/... rust-skia 预构建的逐字节镜像
mcpplibs/slint-m
src/*.cppm include/mwrap/slint/macros.hpp rules/(slintgen,模块 mcpp.plugins.slint) templates/hello tests tools
src/*.cppm include/mwrap/slint/macros.hpp rules/(slintgen,模块 slint.mcpp.plugins) templates/hello tests tools
```

## 4. compat.slint
Expand Down Expand Up @@ -114,7 +115,7 @@ feature 名与上游 cargo 功能名逐一相同(kebab-case,与 mwrap 规范
(如 `mcpp:slint-runtime`)互斥,`mcpplibs.mwrap.slint` 的 feature 经 `feature-deps` 选择提供者;或单一包内由
install / build 程序按功能集选择载荷。以 S2 的实测结果定稿。

## 5. 构建规则 mcpp.plugins.slint(slint-m 的 rules/)
## 5. 构建规则 slint.mcpp.plugins(slint-m 的 rules/)

### 5.1 形态

Expand All @@ -125,7 +126,7 @@ mcpp.plugins = { version = "0.26.1", features = ["plugins-core"] }

[features.slint]
sources = ["src/slint.cppm"]
rule_module = "mcpp.plugins.slint"
rule_module = "slint.mcpp.plugins"
device_extensions = [".slint"]
```
与 `rules-qt` 相同:不声明 SDK、不固定版本。`slint-compiler` 的来源按序:`options::compiler`;环境变量 `SLINT_COMPILER`;
Expand Down Expand Up @@ -174,7 +175,7 @@ device_extensions = [".slint"]
| 阶段 | 交付 | 验收 |
|---|---|---|
| 0(实测) | S1–S3(§9) | 结论写回本文 |
| 1 | xlings-res `slint` 的 `default` 档(4 平台,GLOBAL + CN);compat.slint 1.19.0(default 档,feature 与上游同名);`mcpp.plugins.slint`;slint-m(核心、`.interpreter`、`.platform`、`.macros`)与 `hello` 模板 | Linux(gcc/llvm)、Linux arm64、macOS、Windows 的 CI:模板严格构建并无头运行;规则的增量测试;运行时依赖闭包只含声明的提供者;导出审计 |
| 1 | xlings-res `slint` 的 `default` 档(4 平台,GLOBAL + CN);compat.slint 1.19.0(default 档,feature 与上游同名);`slint.mcpp.plugins`;slint-m(核心、`.interpreter`、`.platform`、`.macros`)与 `hello` 模板 | Linux(gcc/llvm)、Linux arm64、macOS、Windows 的 CI:模板严格构建并无头运行;规则的增量测试;运行时依赖闭包只含声明的提供者;导出审计 |
| 2 | `slint-vendor` 载荷;源码构建路径(任意功能组合) | 一个非档位组合(如 `default` + `gettext`)冷构建与二次缓存命中 |
| 3 | `skia-binaries` 镜像;`full` 档;`renderer-skia*` | CN 镜像下无 GitHub 访问构建成功;Skia 渲染无头截图比对 |
| 4 | linuxkms(compat.libinput soname)、Android / iOS / wasm / MCU 行、`backend-qt`、`gettext` | 各平台行的模板构建;KMS 以无显示设备的冒烟测试 |
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,13 @@ jobs:
shell: bash
run: python3 tests/mwrap/check_installed_template.py --mcpp "$MCPP" --package mcpplibs.mwrap.sheenbidi@3.0.0 --deploy

- name: Installed Slint wrapper archive, actual default hello template (headless) and its relocated notices
if: contains(format(' {0} ', env.MEMBERS), ' slint-ui ') && matrix.toolchain == 'default'
shell: bash
env:
SLINT_HEADLESS: "1"
run: python3 tests/mwrap/check_installed_template.py --mcpp "$MCPP" --package mcpplibs.mwrap.slint@1.19.0.1 --deploy

- name: Installed Wuffs wrapper archive, actual default decode template and its relocated notices
if: contains(format(' {0} ', env.MEMBERS), ' wuffs-decode ') && matrix.toolchain == 'default'
shell: bash
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Added

- **mcpplibs.mwrap.slint 1.19.0.1:slint-m,Slint 作为 C++23 模块;mcpplibs.slintgen 1.19.0.1:构建规则,模块 `slint.mcpp.plugins`。** 模块 `mcpplibs.mwrap.slint`(slint、slint::language)、`.interpreter`、`.platform`(仅 Clang;GCC 16 在包着 `slint-platform.h` 的模块上 ICE,故以文本 `#include` 提供)与 `.macros`(13 个 `SLINT_FEATURE_*` 常量),导出面由 SDK 头文件的 AST 生成并审计;链接 compat.slint 1.19.0。规则包 slintgen(同一归档的 `rules/`,与 grpcgen 同形)为每个 `.slint` 文件运行 `slint-compiler`(上游 `slint_target_sources` 的选项、每个输入一条带 depfile 的 action),设置 `module` 后每个文件还生成一个模块单元(`import app.ui;`);工程在 `[build-dependencies]` 写 `features = ["slint"]` 以认领 `.slint`。模块以库名命名而不用 `mcpp.plugins.*`(R9.6 把它留给 mcpp 命名空间,索引不收录此类包);1.19.0 已打标签与镜像但未收录,改名以修订号 1.19.0.1 发布。成员 tests/mwrap/slint-ui;默认模板 `hello`(无头时用软件渲染器)。Linux x86_64、macOS arm64、Windows x86_64(compat.slint 的载荷暂无 Linux aarch64)。
- **compat.slint 1.19.0:Slint 的 C++ SDK(`libslint_cpp`、头文件 `slint/`、`slint-compiler`),上游 CMake 的桌面默认功能集(GPL-3.0-only / Royalty-free-2.0 / Software-3.0 三选一)。** 载荷是生态里的 `xim:slint`(xlings-res/slint,GitHub 与 GitCode 逐字节相同;Linux x86_64、macOS arm64、Windows x86_64),由发布 tag 经 cargo 按默认功能集构建:Linux 上 `libslint_cpp` 只 NEEDED fontconfig 与 C 运行时(X11、Wayland、GL 均 dlopen)。描述符把载荷的 include、lib(Windows 为 bin 的 DLL)与 `slint-compiler` 放进包的目录,`SLINT_FEATURE_*` 由 `<slint.h>` 的默认功能集定义。成员 tests/examples/slint:SharedString、VectorModel、Color,解释器编译一段源码并在无头平台上驱动组件。Linux aarch64 暂缺:`xim:fontconfig` 尚无 aarch64 载荷。
- **mcpplibs.mwrap.wuffs 0.3.6:wuffs-m(Wuffs 的 C++23 模块),基于 compat.wuffs 0.3.6。** 每个上游包一个模块(`.base`、`.png`、`.gif`、`.json`、`.gzip` 等 16 个)、`.aux`(`wuffs_aux`)与 `.macros`;由 clang AST 生成并审计:429 个全局名导出,315 个 `static inline` 函数在 `mcpplibs::mwrap::wuffs` 中同名同签名适配,296 个宏常量与 34 个函数名宏映射,11 个附原因列出。上游 `convert-to-nia` 的模块移植版与上游程序在 `test/data` 的 246 个文件上逐字节一致,82/82 个 NIA 校验和一致。成员 tests/mwrap/wuffs-decode;validate.yml 以真实归档做已安装模板与部署通知检查。CN:mcpp-res/mwrap-wuffs。
- **compat.wuffs 0.3.6:Google 的 Wuffs,面向不可信文件格式的内存安全解码器(Apache-2.0)。** 上游只发布单文件 `release/c/wuffs-v0.3.c`:本包取 tag 归档,以一个生成的翻译单元在 `WUFFS_IMPLEMENTATION` 下按 C++ 编译,C API(`extern "C"`)与只在 C++ 下定义的 `wuffs_aux`(DecodeImage、DecodeJson、DecodeCbor)都在同一个库里;使用者按上游写法 `#include <wuffs-v0.3.c>`。成员 tests/examples/wuffs:版本串、gzip 经 C API、CRC-32 与 Adler-32 的标准校验值、PNG 经 DecodeImage 逐像素、截断 PNG 被拒绝、JSON 遍历。0.4 线上游仍为 alpha。
Expand Down
1 change: 1 addition & 0 deletions mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"tests/mwrap/pocketpy-embed",
"tests/mwrap/libpng-image",
"tests/mwrap/libwebp-image",
"tests/mwrap/slint-ui",
"tests/mwrap/wuffs-decode",
"tests/mwrap/concurrentqueue-mpmc",
"tests/mwrap/fribidi-bidi",
Expand Down
56 changes: 56 additions & 0 deletions pkgs/mwrap/slint.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- Immutable upstream-aligned mwrap source release (slint-m mwrap-1.19.0.1);
-- GLOBAL and CN bytes are identical.
--
-- The wrapper is Apache-2.0. The library it links, compat.slint (Slint 1.19.0,
-- upstream CMake's desktop default features), is Slint's own three-way
-- license (GPL-3.0-only, Royalty-free-2.0 or the Software license, at the
-- user's choice); the package deploys Slint's README, LICENSE.md and the three
-- license texts beside programs (runtime.deploy). Linux x86_64, macOS arm64 and
-- Windows x86_64: compat.slint's payload has no Linux aarch64 row yet.
--
-- The build rule slint.mcpp.plugins is the separate package mcpplibs.slintgen
-- (rules/ of the same archive).
package = {
spec = "1",
namespace = "mcpplibs.mwrap",
name = "slint",
description = "slint-m: Slint (declarative GUI toolkit) as C++23 modules: the runtime API, the interpreter, the platform API and the features as constants",
licenses = { "Apache-2.0" },
repo = "https://github.com/mcpplibs/slint-m",
type = "package",
extensions = {
autoupdate = {
tag = "mwrap-${version}",
url = "https://github.com/mcpplibs/slint-m/releases/download/${tag}/slint-m-${version}.tar.gz",
},
},
xpm = {
linux = {
["1.19.0.1"] = {
url = {
GLOBAL = "https://github.com/mcpplibs/slint-m/releases/download/mwrap-1.19.0.1/slint-m-1.19.0.1.tar.gz",
CN = "https://gitcode.com/mcpp-res/mwrap-slint/releases/download/1.19.0.1/slint-m-1.19.0.1.tar.gz",
},
sha256 = "ed0da17d0e0394eba430b0e877c270251710885024f35cbb2ec1e7a71c0b7ee2",
},
},
macosx = {
["1.19.0.1"] = {
url = {
GLOBAL = "https://github.com/mcpplibs/slint-m/releases/download/mwrap-1.19.0.1/slint-m-1.19.0.1.tar.gz",
CN = "https://gitcode.com/mcpp-res/mwrap-slint/releases/download/1.19.0.1/slint-m-1.19.0.1.tar.gz",
},
sha256 = "ed0da17d0e0394eba430b0e877c270251710885024f35cbb2ec1e7a71c0b7ee2",
},
},
windows = {
["1.19.0.1"] = {
url = {
GLOBAL = "https://github.com/mcpplibs/slint-m/releases/download/mwrap-1.19.0.1/slint-m-1.19.0.1.tar.gz",
CN = "https://gitcode.com/mcpp-res/mwrap-slint/releases/download/1.19.0.1/slint-m-1.19.0.1.tar.gz",
},
sha256 = "ed0da17d0e0394eba430b0e877c270251710885024f35cbb2ec1e7a71c0b7ee2",
},
},
},
}
60 changes: 60 additions & 0 deletions pkgs/s/slintgen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- slintgen -- slint-compiler as an importable build rule (module slint.mcpp.plugins).
--
-- [build-dependencies]
-- mcpplibs.slintgen = { version = "1.19.0.1", features = ["slint"] }
--
-- // build.mcpp
-- import mcpp;
-- import slint.mcpp.plugins;
-- int main() { return mcpp::plugins::slint::compile({}) ? 0 : 1; }
--
-- The rule is this ecosystem's own C++ (not upstream's), so it stays in
-- `mcpplibs`; it ships in the rules/ directory of the slint-m archive, as
-- grpcgen ships in grpc-m's. The feature `slint` claims `.slint` as a source
-- the rule compiles; the project names it.
--
-- The module is named under the library's name, not `mcpp.plugins.*`: SPEC-007
-- R9.6 keeps that for the mcpp namespace and the index admits no package that
-- provides such a module (tests/run_members.sh). 1.19.0.1 is the wrapper
-- revision that renamed it; mwrap-1.19.0 was tagged and never indexed.
package = {
spec = "1",
namespace = "mcpplibs",
name = "slintgen",
description = "slint-compiler as an importable mcpp build rule (host-module slint.mcpp.plugins)",
licenses = {"Apache-2.0"},
repo = "https://github.com/mcpplibs/slint-m",
type = "package",

xpm = {
linux = {
["1.19.0.1"] = {
url = {
GLOBAL = "https://github.com/mcpplibs/slint-m/releases/download/mwrap-1.19.0.1/slint-m-1.19.0.1.tar.gz",
CN = "https://gitcode.com/mcpp-res/mwrap-slint/releases/download/1.19.0.1/slint-m-1.19.0.1.tar.gz",
},
sha256 = "ed0da17d0e0394eba430b0e877c270251710885024f35cbb2ec1e7a71c0b7ee2",
},
},
macosx = {
["1.19.0.1"] = {
url = {
GLOBAL = "https://github.com/mcpplibs/slint-m/releases/download/mwrap-1.19.0.1/slint-m-1.19.0.1.tar.gz",
CN = "https://gitcode.com/mcpp-res/mwrap-slint/releases/download/1.19.0.1/slint-m-1.19.0.1.tar.gz",
},
sha256 = "ed0da17d0e0394eba430b0e877c270251710885024f35cbb2ec1e7a71c0b7ee2",
},
},
windows = {
["1.19.0.1"] = {
url = {
GLOBAL = "https://github.com/mcpplibs/slint-m/releases/download/mwrap-1.19.0.1/slint-m-1.19.0.1.tar.gz",
CN = "https://gitcode.com/mcpp-res/mwrap-slint/releases/download/1.19.0.1/slint-m-1.19.0.1.tar.gz",
},
sha256 = "ed0da17d0e0394eba430b0e877c270251710885024f35cbb2ec1e7a71c0b7ee2",
},
},
},

mcpp = "*/rules/mcpp.toml",
}
1 change: 1 addition & 0 deletions tests/mwrap/check_installed_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"mcpplibs.mwrap.libc": ("libc.cppm", None, b"", b"ISO/IEC 9899:2018"),
"mcpplibs.mwrap.abseil": ("abseil.cppm", "upstream/abseil-cpp/LICENSE", b"Apache License", b"The Abseil Authors"),
"mcpplibs.mwrap.openssl": ("openssl.cppm", "upstream/openssl/LICENSE.txt", b"Apache License", b"The OpenSSL Project Authors"),
"mcpplibs.mwrap.slint": ("slint.cppm", "upstream/slint/LICENSE.md", b"Slint License", b"SixtyFPS"),
"mcpplibs.mwrap.wuffs": ("wuffs.cppm", "upstream/wuffs/LICENSE", b"Apache License", b"The Wuffs Authors"),
"mcpplibs.mwrap.protobuf": ("protobuf.cppm", "upstream/protobuf/LICENSE", b"Redistribution and use in source and binary forms", b"Google"),
}
Expand Down
12 changes: 12 additions & 0 deletions tests/mwrap/slint-ui/build.mcpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// `ui/app.slint` reaches slint.mcpp.plugins from `[build] sources`; the module
// `app.ui` exports what the file exports and slint-compiler generates. The SDK
// is compat.slint, reached through mcpplibs.mwrap.slint.
import mcpp;
import slint.mcpp.plugins;

int main() {
mcpp::plugins::slint::options o;
o.module = "app.ui";
o.style = "fluent";
return mcpp::plugins::slint::compile(o) ? 0 : 1;
}
27 changes: 27 additions & 0 deletions tests/mwrap/slint-ui/mcpp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "slint-ui"
version = "1.19.0.1"
description = "Consume the immutable Slint wrapper: the runtime types and the interpreter through the modules, a .slint file compiled by slint.mcpp.plugins into the module app.ui, a component driven headless, the features as constants"

[language]
standard = "c++23"
modules = true
import_std = false

[indices]
# Use the complete candidate built-in index prepared by tests/run_members.sh.
# An explicit empty table overrides the legacy workspace redirect.

[dependencies]
mcpplibs.mwrap.slint = "1.19.0.1"

# The build rule (module slint.mcpp.plugins): the project names the feature that claims `.slint`.
[build-dependencies]
mcpplibs.slintgen = { version = "1.19.0.1", features = ["slint"] }

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

[targets.slint-ui]
kind = "bin"
main = "src/main.cpp"
Loading
Loading