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: slint.mcpp.plugins generates a component, its module, and runs it headless with the SDK the project declares
- name: mcpp.mcpplibs.slintgen 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
21 changes: 8 additions & 13 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 `slint.mcpp.plugins` (package
default features). A `.slint` file is compiled by `mcpp.mcpplibs.slintgen` (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` (`slint.mcpp.plugins`, `options::module`)
- `import app.ui;`: a component of yours, from `ui/app.slint` (`mcpp.mcpplibs.slintgen`, `options::module`)

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

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

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

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

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

```cpp
// build.mcpp
import mcpp;
import slint.mcpp.plugins;
import mcpp.mcpplibs.slintgen;
int main() {
mcpp::plugins::slint::options o;
mcpp::mcpplibs::slintgen::options o;
o.sources = {"ui/app.slint"};
o.module = "app.ui";
return mcpp::plugins::slint::compile(o) ? 0 : 1;
return mcpp::mcpplibs::slintgen::compile(o) ? 0 : 1;
}
```

Expand Down Expand Up @@ -90,7 +85,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 `slint.mcpp.plugins` and runs it
template as an installed package, builds it with `mcpp.mcpplibs.slintgen` and runs it
headless.

## License
Expand Down
21 changes: 8 additions & 13 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` 文件由 `slint.mcpp.plugins`(包 `mcpplibs.slintgen`,在本仓库的 `rules/`)编译,
默认功能构建)。`.slint` 文件由 `mcpp.mcpplibs.slintgen`(包 `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`(`slint.mcpp.plugins` 的 `options::module`)
- `import app.ui;`:你自己的组件,来自 `ui/app.slint`(`mcpp.mcpplibs.slintgen` 的 `options::module`)

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

Expand All @@ -38,23 +38,18 @@ mcpp run

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

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

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

```cpp
// build.mcpp
import mcpp;
import slint.mcpp.plugins;
import mcpp.mcpplibs.slintgen;
int main() {
mcpp::plugins::slint::options o;
mcpp::mcpplibs::slintgen::options o;
o.sources = {"ui/app.slint"};
o.module = "app.ui";
return mcpp::plugins::slint::compile(o) ? 0 : 1;
return mcpp::mcpplibs::slintgen::compile(o) ? 0 : 1;
}
```

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

## 许可

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

`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.
`mcpp.mcpplibs.slintgen` 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.mcpplibs.slintgen`; engine floor 2026.10.1.3.

## Use

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

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

[build]
sources = ["src/*.cpp", "ui/app.slint"]
mcpplibs.mwrap.slint = "1.19.0.2" # re-exports this rule and the SDK (compat.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 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`.
The wrapper hands the rule to the project's build program, so this one dependency is enough. A project that does not use the wrapper writes `mcpplibs.slintgen = { version = "1.19.0.2", host-module = true }` under `[build-dependencies]` and depends on `compat.slint` for the SDK.

One name in three spellings, as `mcpplibs.openkal-bind` is (SPEC-007 R9.6, a third-party plugin's `mcpp.<namespace>.<name>`): package `mcpplibs.slintgen`, module `mcpp.mcpplibs.slintgen`, C++ namespace `mcpp::mcpplibs::slintgen`.

The `.slint` files are the rule's `options::sources`, relative to the package root; they are not listed in `[build] sources`, which mcpp reads as C++.

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

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

Expand All @@ -42,7 +41,7 @@ int main() {

| `slint_target_sources` / target property | option | `slint-compiler` |
|---|---|---|
| the `.slint` inputs | `[build] sources`, `options::sources` | the input |
| the `.slint` inputs | `options::sources` | the input |
| `NAMESPACE` | `ns` | `--cpp-namespace` |
| `LIBRARY_PATHS name=path` | `library_paths` | `-L name=path` |
| — | `include_paths` | `-I` |
Expand All @@ -68,7 +67,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 `slint.mcpp.plugins.sdk`:
The first that answers decides, recorded as the fact `mcpp.mcpplibs.slintgen.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

`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).
`mcpp.mcpplibs.slintgen` (package `mcpplibs.slintgen`, `rules/` of this repository; this package re-exports it to the project's build program, and compat.slint re-exports `slint-compiler`) runs `slint-compiler` on each `.slint` file the build program names in `options::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
14 changes: 10 additions & 4 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.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"
version = "1.19.0.2"
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.mcpplibs.slintgen"
license = "Apache-2.0"
authors = ["mcpp-community"]
repo = "https://github.com/mcpplibs/slint-m"
Expand All @@ -19,10 +19,16 @@ 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
# slint.mcpp.plugins, package mcpplibs.slintgen, is rules/ of this repository).
# consumer's build program finds slint-compiler in it.
compat.slint = { version = "1.19.0", reexport = true }

# The build rule (module mcpp.mcpplibs.slintgen, rules/): handed to the
# consumer's build program, so this one dependency is enough to import it in
# build.mcpp -- the shape grpc-m gives grpcgen. It runs slint-compiler from
# compat.slint above: one SDK, one version.
[build-dependencies]
mcpplibs.slintgen = { path = "rules", host-module = true, reexport = true }

[package.metadata.mwrap]
upstream-version = "1.19.0"

Expand Down
36 changes: 17 additions & 19 deletions rules/mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
# slintgen — how a `.slint` file becomes part of a C++ program, as a package.
#
# The module is `slint.mcpp.plugins` (rules/src/slint.cppm). A consumer's
# The module is `mcpp.mcpplibs.slintgen` (rules/src/slint.cppm). A consumer's
# build.mcpp imports it:
#
# import mcpp;
# import slint.mcpp.plugins;
# int main() { return mcpp::plugins::slint::compile({}) ? 0 : 1; }
# import mcpp.mcpplibs.slintgen;
# int main() { return mcpp::mcpplibs::slintgen::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. 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.
# release, this repository the one that is.
#
# One name in three spellings, as mcpplibs.openkal-bind is (SPEC-007 R9.6, a
# third-party plugin's `mcpp.<namespace>.<name>`):
#
# package mcpplibs.slintgen
# module mcpp.mcpplibs.slintgen
# namespace mcpp::mcpplibs::slintgen
#
# mcpplibs.mwrap.slint re-exports it, so a project that depends on the wrapper
# imports the module in its build.mcpp and passes its `.slint` files as
# `options::sources`.
#
# Versioned with slint-m (and so with the Slint it is built against).
[package]
name = "slintgen"
version = "1.19.0.1"
version = "1.19.0.2"
standard = "c++23"
description = "slint-compiler as an importable mcpp build rule (module slint.mcpp.plugins)"
description = "slint-compiler as an importable mcpp build rule (module mcpp.mcpplibs.slintgen)"
license = "Apache-2.0"
repo = "https://github.com/mcpplibs/slint-m"
platforms = ["linux", "macos", "windows"]
Expand All @@ -31,15 +39,5 @@ platforms = ["linux", "macos", "windows"]
[dependencies]
mcpp.plugins = { version = "0.26.1", features = ["plugins-core"] }

# `.slint` is no extension the engine knows: the feature claims it, so a project
# lists `ui/app.slint` in `[build] sources` and the rule submits its action.
[features]
default = []

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

[targets.slintgen]
kind = "lib"
Loading
Loading