From 3fd218a4fab800b3f1fcb1e30f20ceff36a2c9be Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Fri, 20 Nov 2026 23:30:24 +0900 Subject: [PATCH] slint-m 1.19.0.2: one name for the rule in three spellings; the wrapper re-exports it, so a project depends on the wrapper alone package mcpplibs.slintgen, module mcpp.mcpplibs.slintgen, namespace mcpp::mcpplibs::slintgen (the shape of mcpplibs.openkal-bind under SPEC-007 R9.6). The rule has no feature: the .slint files are options::sources, so mcpp.toml needs no [build-dependencies] and no .slint in [build] sources. Root mcpp.toml re-exports the rule (grpc-m's grpcgen shape). Template, fixture and docs follow. --- .github/workflows/ci.yml | 2 +- README.md | 21 ++++++---------- README.zh.md | 21 ++++++---------- docs/rules.md | 29 +++++++++++----------- docs/usage.md | 2 +- mcpp.toml | 14 ++++++++--- rules/mcpp.toml | 36 +++++++++++++-------------- rules/src/slint.cppm | 39 +++++++++--------------------- src/slint.cppm | 2 +- templates/hello/build.mcpp.in | 11 +++++---- templates/hello/mcpp.toml.in | 11 ++------- templates/hello/src/main.cpp.in | 2 +- templates/hello/template.toml | 2 +- tests/rule-consumer/build.mcpp | 9 ++++--- tests/rule-consumer/check-slint.sh | 2 +- tests/rule-consumer/mcpp.toml | 8 +++--- tools/gen_exports.py | 2 +- 17 files changed, 93 insertions(+), 120 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0877588..d487ce5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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) diff --git a/README.md b/README.md index 579f0cf..072398b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The upstream API is unchanged: `slint::ComponentHandle`, `slint::SharedString`, `slint::VectorModel`, `slint::interpreter::ComponentCompiler` are the names of ``. 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. @@ -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 ``) - `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) @@ -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; } ``` @@ -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 diff --git a/README.zh.md b/README.zh.md index a66ecd0..0d6471c 100644 --- a/README.zh.md +++ b/README.zh.md @@ -12,7 +12,7 @@ 上游 API 保持不变:`slint::ComponentHandle`、`slint::SharedString`、`slint::VectorModel`、 `slint::interpreter::ComponentCompiler` 就是 `` 里的名字。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 的模块。 ## 模块 @@ -21,7 +21,7 @@ - `import mcpplibs.mwrap.slint.interpreter;`:`slint::interpreter`,运行时加载 `.slint` 源码 - `import mcpplibs.mwrap.slint.platform;`:`slint::platform`,自定义平台与软件渲染器(Clang;GCC 下请 include ``) - `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) @@ -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; } ``` @@ -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` 构建并无头运行。 ## 许可 diff --git a/docs/rules.md b/docs/rules.md index a1e0ed4..9de12d9 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -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..`): 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; } ``` @@ -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` | @@ -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 | |---|---| diff --git a/docs/usage.md b/docs/usage.md index 0c3084d..22ee520 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -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 diff --git a/mcpp.toml b/mcpp.toml index deec994..4e46704 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -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" @@ -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" diff --git a/rules/mcpp.toml b/rules/mcpp.toml index decbc0d..8021026 100644 --- a/rules/mcpp.toml +++ b/rules/mcpp.toml @@ -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..`): +# +# 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"] @@ -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" diff --git a/rules/src/slint.cppm b/rules/src/slint.cppm index 5ff874a..24a3ecc 100644 --- a/rules/src/slint.cppm +++ b/rules/src/slint.cppm @@ -1,4 +1,4 @@ -// slint.mcpp.plugins -- how a `.slint` file becomes part of a C++ program. +// mcpp.mcpplibs.slintgen -- 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 @@ -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("slint.mcpp.plugins.sdk", …)` records it: +// that answers decides, and `mcpp::fact("mcpp.mcpplibs.slintgen.sdk", …)` records it: // // 1. `options::compiler` / `options::root` in the build program; // 2. the environment variable `SLINT_COMPILER` (upstream CMake's cache @@ -51,14 +51,14 @@ // 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 slint.mcpp.plugins; +export module mcpp.mcpplibs.slintgen; import std; import mcpp; import mcpp.plugins; import mcpp.plugins.tool; -export namespace mcpp::plugins::slint { +export namespace mcpp::mcpplibs::slintgen { struct library_path { std::string name; // the name `import { X } from "@name"` uses @@ -66,7 +66,7 @@ struct library_path { }; struct options { - // `.slint` files, beside those named in `[build] sources`. + // The `.slint` files, relative to the package root. std::vector sources; std::string ns; // --cpp-namespace std::vector library_paths; // -L name=path @@ -114,20 +114,6 @@ inline fs::path absolute_from_root(const std::string& p) { return path.is_absolute() ? path : fs::path(mcpp::manifest_dir()) / path; } -inline std::vector device_slint() { - std::vector out; - const std::string all = mcpp::device_sources(); - std::size_t i = 0; - while (i <= all.size()) { - auto nl = all.find('\n', i); - std::string one = all.substr(i, nl == std::string::npos ? std::string::npos : nl - i); - i = nl == std::string::npos ? all.size() + 1 : nl + 1; - while (!one.empty() && (one.back() == ' ' || one.back() == '\r')) one.pop_back(); - if (one.size() > 6 && one.ends_with(".slint")) out.push_back(one); - } - return out; -} - inline std::string read_file(const fs::path& p) { std::ifstream in(p, std::ios::binary); return {std::istreambuf_iterator(in), {}}; @@ -320,7 +306,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 = "slint.mcpp.plugins", .ns = "xim", .package = "slint", + tool::spec s{.who = "mcpp.mcpplibs.slintgen", .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)); @@ -336,7 +322,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 = "slint.mcpp.plugins", .ns = "xim", .package = "slint", + tool::spec s{.who = "mcpp.mcpplibs.slintgen", .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"}; @@ -348,11 +334,10 @@ inline sdk locate(const options& opt) { inline bool compile(options opt = {}) { namespace fs = std::filesystem; using detail::generic; - const char* who = "slint.mcpp.plugins"; + const char* who = "mcpp.mcpplibs.slintgen"; mcpp::fact("mcpp.plugins", std::string(mcpp::plugins::version).c_str()); - std::vector inputs = detail::device_slint(); - for (auto const& s : opt.sources) inputs.push_back(s); + const std::vector& inputs = opt.sources; if (inputs.empty()) return true; const detail::sdk sdk = detail::locate(opt); @@ -363,7 +348,7 @@ inline bool compile(options opt = {}) { "name it with options::compiler. Nothing is generated.", who, inputs.size())); return true; } - mcpp::fact("slint.mcpp.plugins.sdk", std::format("{}: {}", sdk.level, sdk.compiler).c_str()); + mcpp::fact("mcpp.mcpplibs.slintgen.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. @@ -433,7 +418,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 slint.mcpp.plugins from {} -- do not edit.\n" + "// Generated by mcpp.mcpplibs.slintgen from {} -- do not edit.\n" "module;\n#include \n#include \n#include \n#include \"{}.h\"\n\n" "export module {};\n\n", f.filename().string(), stem, module); if (opt.ns.empty()) { @@ -453,4 +438,4 @@ inline bool compile(options opt = {}) { return true; } -} // namespace mcpp::plugins::slint +} // namespace mcpp::mcpplibs::slintgen diff --git a/src/slint.cppm b/src/slint.cppm index 407879b..0c0b53c 100644 --- a/src/slint.cppm +++ b/src/slint.cppm @@ -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 (slint.mcpp.plugins) is used beside this module. +// `.slint` file (mcpp.mcpplibs.slintgen) is used beside this module. module; #include diff --git a/templates/hello/build.mcpp.in b/templates/hello/build.mcpp.in index 945b1a8..8226668 100644 --- a/templates/hello/build.mcpp.in +++ b/templates/hello/build.mcpp.in @@ -1,11 +1,12 @@ -// ui/app.slint -> app.h and `export module app.ui;` (slint.mcpp.plugins, which -// package mcpplibs.slintgen runs on the SDK compat.slint provides). +// ui/app.slint -> app.h and `export module app.ui;` (mcpp.mcpplibs.slintgen, which +// mcpplibs.mwrap.slint hands to this build program, on the SDK compat.slint provides). 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"; o.edition = "1.19"; - return mcpp::plugins::slint::compile(o) ? 0 : 1; + return mcpp::mcpplibs::slintgen::compile(o) ? 0 : 1; } diff --git a/templates/hello/mcpp.toml.in b/templates/hello/mcpp.toml.in index 09d0382..fea6d74 100644 --- a/templates/hello/mcpp.toml.in +++ b/templates/hello/mcpp.toml.in @@ -6,14 +6,7 @@ version = "0.1.0" kind = "bin" main = "src/main.cpp" -[build] -# ui/app.slint reaches slint.mcpp.plugins, which writes app.h and the module app.ui. -sources = ["src/*.cpp", "ui/app.slint"] - +# build.mcpp compiles ui/app.slint into app.h and the module app.ui +# (mcpp.mcpplibs.slintgen, which the wrapper hands to the build program). [dependencies] {{self.name}} = "{{self.version}}" - -# The build rule: ui/app.slint -> app.h and the module app.ui. Its feature -# classifies `.slint` as a source the rule claims. -[build-dependencies] -mcpplibs.slintgen = { version = "{{self.version}}", features = ["slint"] } diff --git a/templates/hello/src/main.cpp.in b/templates/hello/src/main.cpp.in index 67aaf12..d5ba8db 100644 --- a/templates/hello/src/main.cpp.in +++ b/templates/hello/src/main.cpp.in @@ -1,5 +1,5 @@ // {{project.name}} -- a Slint window: ui/app.slint is compiled into the module -// app.ui (slint.mcpp.plugins), the counter lives in C++. +// app.ui (mcpp.mcpplibs.slintgen), 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 diff --git a/templates/hello/template.toml b/templates/hello/template.toml index c42d455..09202da 100644 --- a/templates/hello/template.toml +++ b/templates/hello/template.toml @@ -1,4 +1,4 @@ [template] -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++" +description = "A Slint window with import mcpplibs.mwrap.slint: ui/app.slint compiled by mcpp.mcpplibs.slintgen 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." diff --git a/tests/rule-consumer/build.mcpp b/tests/rule-consumer/build.mcpp index 76d8180..83653e6 100644 --- a/tests/rule-consumer/build.mcpp +++ b/tests/rule-consumer/build.mcpp @@ -1,14 +1,15 @@ -// `.slint` files reach the rule from `[build] sources`; the module `app.ui` +// The `.slint` file reaches the rule as `options::sources`; the module `app.ui` // exports what ui/app.slint exports and slint-compiler generates. import std; 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"; o.style = "fluent"; // CI declares xim:slint in [xlings]; a local run may point at an SDK. if (const char* root = std::getenv("SLINT_SDK_ROOT"); root && *root) o.root = root; - return mcpp::plugins::slint::compile(o) ? 0 : 1; + return mcpp::mcpplibs::slintgen::compile(o) ? 0 : 1; } diff --git a/tests/rule-consumer/check-slint.sh b/tests/rule-consumer/check-slint.sh index fbb8a53..f2cc6c5 100755 --- a/tests/rule-consumer/check-slint.sh +++ b/tests/rule-consumer/check-slint.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# slint.mcpp.plugins end to end: the fixture builds with the SDK the project declares +# mcpp.mcpplibs.slintgen 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. diff --git a/tests/rule-consumer/mcpp.toml b/tests/rule-consumer/mcpp.toml index a2e93d3..e013c8f 100644 --- a/tests/rule-consumer/mcpp.toml +++ b/tests/rule-consumer/mcpp.toml @@ -1,4 +1,4 @@ -# Fixture: a Slint user interface compiled by slint.mcpp.plugins, run headless. +# Fixture: a Slint user interface compiled by mcpp.mcpplibs.slintgen, 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 @@ -11,7 +11,7 @@ [package] name = "slint-consumer" version = "0.1.0" -description = "Fixture: a Slint UI built through slint.mcpp.plugins" +description = "Fixture: a Slint UI built through mcpp.mcpplibs.slintgen" license = "Apache-2.0" authors = ["mcpp-community"] @@ -21,14 +21,14 @@ modules = true import_std = false [build-dependencies] -mcpplibs.slintgen = { path = "../../rules", features = ["slint"] } +mcpplibs.slintgen = { path = "../../rules", host-module = true } # The SDK is the project's declaration, at the version it chooses. [target.'cfg(any(windows, linux, macos))'.xlings.workspace] "xim:slint" = "1.19.0" [build] -sources = ["src/*.cpp", "ui/app.slint"] +sources = ["src/*.cpp"] [targets.slint-consumer] kind = "bin" diff --git a/tools/gen_exports.py b/tools/gen_exports.py index ee9eeca..a9fe08c 100644 --- a/tools/gen_exports.py +++ b/tools/gen_exports.py @@ -38,7 +38,7 @@ def core_unit(sf) -> str: '// 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 (slint.mcpp.plugins) is used beside this module.', + '// `.slint` file (mcpp.mcpplibs.slintgen) is used beside this module.', 'module;', '#include ', '', 'export module mcpplibs.mwrap.slint;', '', 'export import mcpplibs.mwrap.slint.macros;', '', 'export namespace slint {'] out += using_block('slint', sf.names['slint'])