diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d487ce5..c4d4e24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ permissions: contents: read env: - # compat.slint 1.19.0 and mcpplibs.slintgen 1.19.0 are in an mcpp-index + # compat.slint 1.19.0 is in an mcpp-index # PR and not yet in the published index: until they are, the run resolves # against that PR's candidate commit, the complete unchanged index layout # installed as the built-in index of the run's home. Drop this pin and the step @@ -75,7 +75,7 @@ jobs: done mcpp --version - - name: Candidate index (compat.slint, slintgen) + - name: Candidate index (compat.slint) run: | mcpp index update # No early exit in awk: mcpp would take SIGPIPE, and pipefail report it. @@ -101,7 +101,15 @@ jobs: - name: Tests, release profile run: mcpp test --profile release - - name: mcpp.mcpplibs.slintgen generates a component, its module, and runs it headless with the SDK the project declares + - name: The rule's module is its package id (mcpp-index docs/build-plugins.md) + run: | + # A build plugin `.mplugin.` exports a module of exactly that + # name; the index cannot read the archive's sources, so the check is here. + grep -qE '^export module mcpplibs\.mplugin\.slint;' rules/src/slint.cppm + grep -qE '^export namespace mcpplibs::mplugin::slint ' rules/src/slint.cppm + grep -qE '^name += "slint"' rules/mcpp.toml + + - name: mcpplibs.mplugin.slint 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/.github/workflows/templates.yml b/.github/workflows/templates.yml index 993f40b..1e232af 100644 --- a/.github/workflows/templates.yml +++ b/.github/workflows/templates.yml @@ -11,7 +11,7 @@ concurrency: cancel-in-progress: true env: MCPP_VERSION: "2026.11.18.1" - # See ci.yml: the candidate index until compat.slint and mcpplibs.slintgen are published. + # See ci.yml: the candidate index until compat.slint is published. MCPP_INDEX_CANDIDATE: "4191fe3e1193ae4ce4360201ae0a45ca1c2e5463" jobs: templates: diff --git a/README.md b/README.md index 072398b..ff3c50b 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ 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 `mcpp.mcpplibs.slintgen` (package -`mcpplibs.slintgen`, in `rules/` of this repository), which the project's `build.mcpp` +default features). A `.slint` file is compiled by `mcpplibs.mplugin.slint` (package +`mcpplibs.mplugin.slint`, in `rules/` of this repository), which the project's `build.mcpp` imports; with `module` set, each file becomes a module the program imports. ## Modules @@ -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` (`mcpp.mcpplibs.slintgen`, `options::module`) +- `import app.ui;`: a component of yours, from `ui/app.slint` (`mcpplibs.mplugin.slint`, `options::module`) > More Modules API -> [Usage and API](docs/usage.md) @@ -40,18 +40,18 @@ The default template opens a window with a counter; without a display (or with ```toml [dependencies] -mcpplibs.mwrap.slint = "1.19.0.2" +mcpplibs.mwrap.slint = "1.19.0.3" ``` ```cpp // build.mcpp import mcpp; -import mcpp.mcpplibs.slintgen; +import mcpplibs.mplugin.slint; int main() { - mcpp::mcpplibs::slintgen::options o; + mcpplibs::mplugin::slint::options o; o.sources = {"ui/app.slint"}; o.module = "app.ui"; - return mcpp::mcpplibs::slintgen::compile(o) ? 0 : 1; + return mcpplibs::mplugin::slint::compile(o) ? 0 : 1; } ``` @@ -85,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 `mcpp.mcpplibs.slintgen` and runs it +template as an installed package, builds it with `mcpplibs.mplugin.slint` and runs it headless. ## License diff --git a/README.zh.md b/README.zh.md index 0d6471c..d47c1b0 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` 文件由 `mcpp.mcpplibs.slintgen`(包 `mcpplibs.slintgen`,在本仓库的 `rules/`)编译, +默认功能构建)。`.slint` 文件由 `mcpplibs.mplugin.slint`(包 `mcpplibs.mplugin.slint`,在本仓库的 `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`(`mcpp.mcpplibs.slintgen` 的 `options::module`) +- `import app.ui;`:你自己的组件,来自 `ui/app.slint`(`mcpplibs.mplugin.slint` 的 `options::module`) > 更多模块 API -> [用法和 API](docs/usage.md) @@ -38,18 +38,18 @@ mcpp run ```toml [dependencies] -mcpplibs.mwrap.slint = "1.19.0.2" +mcpplibs.mwrap.slint = "1.19.0.3" ``` ```cpp // build.mcpp import mcpp; -import mcpp.mcpplibs.slintgen; +import mcpplibs.mplugin.slint; int main() { - mcpp::mcpplibs::slintgen::options o; + mcpplibs::mplugin::slint::options o; o.sources = {"ui/app.slint"}; o.module = "app.ui"; - return mcpp::mcpplibs::slintgen::compile(o) ? 0 : 1; + return mcpplibs::mplugin::slint::compile(o) ? 0 : 1; } ``` @@ -79,7 +79,7 @@ Linux、macOS 与 Windows 的 CI 用 GCC 和 Clang 构建模块并运行测试 以及由 `slint::interpreter` 在运行时编译组件、在无头平台上通过属性和回调驱动它。导出审计 ([tools/check_exports.py](tools/check_exports.py))读取 SDK 头文件的 clang AST:每个公开名字都已导出, 按键码与功能都已映射,SDK 的功能即上游 CMake 默认值。另有一个任务把默认模板当作已安装包生成项目, -经 `mcpp.mcpplibs.slintgen` 构建并无头运行。 +经 `mcpplibs.mplugin.slint` 构建并无头运行。 ## 许可 diff --git a/docs/rules.md b/docs/rules.md index 9de12d9..d06e663 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -1,29 +1,29 @@ -# `mcpp.mcpplibs.slintgen` +# `mcpplibs.mplugin.slint` -`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. +`mcpplibs.mplugin.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.mplugin.slint` (`rules/` of this repository), module `mcpplibs.mplugin.slint`; engine floor 2026.10.1.3. ## Use ```toml [dependencies] -mcpplibs.mwrap.slint = "1.19.0.2" # re-exports this rule and the SDK (compat.slint) +mcpplibs.mwrap.slint = "1.19.0.3" # re-exports this rule and the SDK (compat.slint) ``` -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. +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.mplugin.slint = { version = "1.19.0", 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`. +One name in three spellings: a build plugin's id is `.mplugin.` (mcpp-index `docs/build-plugins.md`), and its module and C++ namespace are that id: package `mcpplibs.mplugin.slint`, module `mcpplibs.mplugin.slint`, C++ namespace `mcpplibs::mplugin::slint`. The rule's own version is the Slint it drives (`1.19.0`); this wrapper's revisions (`1.19.0.3`) are its own. 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 mcpp.mcpplibs.slintgen; +import mcpplibs.mplugin.slint; int main() { - mcpp::mcpplibs::slintgen::options o; + mcpplibs::mplugin::slint::options o; o.sources = {"ui/app.slint"}; o.module = "app.ui"; // also write `export module app.ui;` - return mcpp::mcpplibs::slintgen::compile(o) ? 0 : 1; + return mcpplibs::mplugin::slint::compile(o) ? 0 : 1; } ``` @@ -67,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 `mcpp.mcpplibs.slintgen.sdk`: +The first that answers decides, recorded as the fact `mcpplibs.mplugin.slint.sdk`: | level | how | |---|---| diff --git a/docs/usage.md b/docs/usage.md index 22ee520..3383078 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -28,7 +28,7 @@ import mcpplibs.mwrap.slint; ## Components from `.slint` files -`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). +`mcpplibs.mplugin.slint` (package `mcpplibs.mplugin.slint`, `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 4e46704..8a788af 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -2,8 +2,8 @@ [package] namespace = "mcpplibs.mwrap" name = "slint" -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" +version = "1.19.0.3" +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 mcpplibs.mplugin.slint" license = "Apache-2.0" authors = ["mcpp-community"] repo = "https://github.com/mcpplibs/slint-m" @@ -22,12 +22,12 @@ include_dirs = ["include"] # 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 +# The build rule (module mcpplibs.mplugin.slint, 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 } +mcpplibs.mplugin.slint = { path = "rules", host-module = true, reexport = true } [package.metadata.mwrap] upstream-version = "1.19.0" diff --git a/rules/LICENSE b/rules/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/rules/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/rules/mcpp.toml b/rules/mcpp.toml index 8021026..26bf4bf 100644 --- a/rules/mcpp.toml +++ b/rules/mcpp.toml @@ -1,33 +1,36 @@ -# slintgen — how a `.slint` file becomes part of a C++ program, as a package. +# mcpplibs.mplugin.slint — how a `.slint` file becomes part of a C++ program, as a package. # -# The module is `mcpp.mcpplibs.slintgen` (rules/src/slint.cppm). A consumer's +# The module is `mcpplibs.mplugin.slint` (rules/src/slint.cppm). A consumer's # build.mcpp imports it: # # import mcpp; -# import mcpp.mcpplibs.slintgen; -# int main() { return mcpp::mcpplibs::slintgen::compile({}) ? 0 : 1; } +# import mcpplibs.mplugin.slint; +# int main() { return mcpplibs::mplugin::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. # -# One name in three spellings, as mcpplibs.openkal-bind is (SPEC-007 R9.6, a -# third-party plugin's `mcpp..`): +# One name in three spellings: a build plugin's id is `.mplugin.` +# (mcpp-index docs/build-plugins.md), and its module and C++ namespace are that +# id, so `mcpp::` (the engine) is never shadowed inside it: # -# package mcpplibs.slintgen -# module mcpp.mcpplibs.slintgen -# namespace mcpp::mcpplibs::slintgen +# package mcpplibs.mplugin.slint +# module mcpplibs.mplugin.slint +# namespace mcpplibs::mplugin::slint # # 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). +# Versioned by the Slint it drives: 1.19.0 is the first release of this package, +# built from the archive of slint-m's tag mwrap-1.19.0.3 (the wrapper's +# revision is not the rule's). [package] -name = "slintgen" -version = "1.19.0.2" +name = "slint" +version = "1.19.0" standard = "c++23" -description = "slint-compiler as an importable mcpp build rule (module mcpp.mcpplibs.slintgen)" +description = "slint-compiler as an importable mcpp build rule (module mcpplibs.mplugin.slint)" license = "Apache-2.0" repo = "https://github.com/mcpplibs/slint-m" platforms = ["linux", "macos", "windows"] @@ -39,5 +42,5 @@ platforms = ["linux", "macos", "windows"] [dependencies] mcpp.plugins = { version = "0.26.1", features = ["plugins-core"] } -[targets.slintgen] +[targets.slint] kind = "lib" diff --git a/rules/src/slint.cppm b/rules/src/slint.cppm index 24a3ecc..ec9e75b 100644 --- a/rules/src/slint.cppm +++ b/rules/src/slint.cppm @@ -1,4 +1,4 @@ -// mcpp.mcpplibs.slintgen -- how a `.slint` file becomes part of a C++ program. +// mcpplibs.mplugin.slint -- 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("mcpp.mcpplibs.slintgen.sdk", …)` records it: +// that answers decides, and `mcpp::fact("mcpplibs.mplugin.slint.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 mcpp.mcpplibs.slintgen; +export module mcpplibs.mplugin.slint; import std; import mcpp; import mcpp.plugins; import mcpp.plugins.tool; -export namespace mcpp::mcpplibs::slintgen { +export namespace mcpplibs::mplugin::slint { struct library_path { std::string name; // the name `import { X } from "@name"` uses @@ -306,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 = "mcpp.mcpplibs.slintgen", .ns = "xim", .package = "slint", + tool::spec s{.who = "mcpplibs.mplugin.slint", .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)); @@ -322,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 = "mcpp.mcpplibs.slintgen", .ns = "xim", .package = "slint", + tool::spec s{.who = "mcpplibs.mplugin.slint", .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"}; @@ -334,7 +334,7 @@ inline sdk locate(const options& opt) { inline bool compile(options opt = {}) { namespace fs = std::filesystem; using detail::generic; - const char* who = "mcpp.mcpplibs.slintgen"; + const char* who = "mcpplibs.mplugin.slint"; mcpp::fact("mcpp.plugins", std::string(mcpp::plugins::version).c_str()); const std::vector& inputs = opt.sources; @@ -348,7 +348,7 @@ inline bool compile(options opt = {}) { "name it with options::compiler. Nothing is generated.", who, inputs.size())); return true; } - mcpp::fact("mcpp.mcpplibs.slintgen.sdk", std::format("{}: {}", sdk.level, sdk.compiler).c_str()); + mcpp::fact("mcpplibs.mplugin.slint.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. @@ -418,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 mcpp.mcpplibs.slintgen from {} -- do not edit.\n" + "// Generated by mcpplibs.mplugin.slint 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()) { @@ -438,4 +438,4 @@ inline bool compile(options opt = {}) { return true; } -} // namespace mcpp::mcpplibs::slintgen +} // namespace mcpplibs::mplugin::slint diff --git a/src/slint.cppm b/src/slint.cppm index 0c0b53c..777929b 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 (mcpp.mcpplibs.slintgen) is used beside this module. +// `.slint` file (mcpplibs.mplugin.slint) is used beside this module. module; #include diff --git a/templates/hello/build.mcpp.in b/templates/hello/build.mcpp.in index 8226668..2b14343 100644 --- a/templates/hello/build.mcpp.in +++ b/templates/hello/build.mcpp.in @@ -1,12 +1,12 @@ -// ui/app.slint -> app.h and `export module app.ui;` (mcpp.mcpplibs.slintgen, which +// ui/app.slint -> app.h and `export module app.ui;` (mcpplibs.mplugin.slint, which // mcpplibs.mwrap.slint hands to this build program, on the SDK compat.slint provides). import mcpp; -import mcpp.mcpplibs.slintgen; +import mcpplibs.mplugin.slint; int main() { - mcpp::mcpplibs::slintgen::options o; + mcpplibs::mplugin::slint::options o; o.sources = {"ui/app.slint"}; o.module = "app.ui"; o.edition = "1.19"; - return mcpp::mcpplibs::slintgen::compile(o) ? 0 : 1; + return mcpplibs::mplugin::slint::compile(o) ? 0 : 1; } diff --git a/templates/hello/mcpp.toml.in b/templates/hello/mcpp.toml.in index fea6d74..4382571 100644 --- a/templates/hello/mcpp.toml.in +++ b/templates/hello/mcpp.toml.in @@ -7,6 +7,6 @@ kind = "bin" main = "src/main.cpp" # 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). +# (mcpplibs.mplugin.slint, which the wrapper hands to the build program). [dependencies] {{self.name}} = "{{self.version}}" diff --git a/templates/hello/src/main.cpp.in b/templates/hello/src/main.cpp.in index d5ba8db..1762fc3 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 (mcpp.mcpplibs.slintgen), the counter lives in C++. +// app.ui (mcpplibs.mplugin.slint), 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 09202da..1165a7e 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 mcpp.mcpplibs.slintgen into the module app.ui, a counter driven from C++" +description = "A Slint window with import mcpplibs.mwrap.slint: ui/app.slint compiled by mcpplibs.mplugin.slint 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 83653e6..fb3496b 100644 --- a/tests/rule-consumer/build.mcpp +++ b/tests/rule-consumer/build.mcpp @@ -2,14 +2,14 @@ // exports what ui/app.slint exports and slint-compiler generates. import std; import mcpp; -import mcpp.mcpplibs.slintgen; +import mcpplibs.mplugin.slint; int main() { - mcpp::mcpplibs::slintgen::options o; + mcpplibs::mplugin::slint::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::mcpplibs::slintgen::compile(o) ? 0 : 1; + return mcpplibs::mplugin::slint::compile(o) ? 0 : 1; } diff --git a/tests/rule-consumer/check-slint.sh b/tests/rule-consumer/check-slint.sh index f2cc6c5..34c8308 100755 --- a/tests/rule-consumer/check-slint.sh +++ b/tests/rule-consumer/check-slint.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# mcpp.mcpplibs.slintgen end to end: the fixture builds with the SDK the project declares +# mcpplibs.mplugin.slint 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 e013c8f..5b72103 100644 --- a/tests/rule-consumer/mcpp.toml +++ b/tests/rule-consumer/mcpp.toml @@ -1,4 +1,4 @@ -# Fixture: a Slint user interface compiled by mcpp.mcpplibs.slintgen, run headless. +# Fixture: a Slint user interface compiled by mcpplibs.mplugin.slint, 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 mcpp.mcpplibs.slintgen" +description = "Fixture: a Slint UI built through mcpplibs.mplugin.slint" license = "Apache-2.0" authors = ["mcpp-community"] @@ -21,7 +21,7 @@ modules = true import_std = false [build-dependencies] -mcpplibs.slintgen = { path = "../../rules", host-module = true } +mcpplibs.mplugin.slint = { 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] diff --git a/tools/gen_exports.py b/tools/gen_exports.py index a9fe08c..4081dc6 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 (mcpp.mcpplibs.slintgen) is used beside this module.', + '// `.slint` file (mcpplibs.mplugin.slint) 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']) diff --git a/tools/test_template.py b/tools/test_template.py index 49db38f..6819021 100644 --- a/tools/test_template.py +++ b/tools/test_template.py @@ -64,15 +64,15 @@ def main(): lines[matches[0]] = identity + " = " + replacement # The build rule is this repository's rules/: the scaffold's dependency on it, which # names the index version a published release has, is the checkout's own copy here. - rule = tomllib.loads(text).get("build-dependencies", {}).get("mcpplibs", {}).get("slintgen") + rule = tomllib.loads(text).get("build-dependencies", {}).get("mcpplibs", {}).get("mplugin", {}).get("slint") if rule is not None: rule = {"version": rule} if isinstance(rule, str) else rule - rule_line = 'mcpplibs.slintgen = { path = ' + json.dumps((package / "rules").as_posix()) + rule_line = 'mcpplibs.mplugin.slint = { path = ' + json.dumps((package / "rules").as_posix()) if rule.get("features"): rule_line += ', features = ' + json.dumps(rule["features"]) rule_line += ' }' - rule_at = [i for i, line in enumerate(lines) if line.startswith("mcpplibs.slintgen =")] - assert len(rule_at) == 1, "Expected exactly one mcpplibs.slintgen build dependency" + rule_at = [i for i, line in enumerate(lines) if line.startswith("mcpplibs.mplugin.slint =")] + assert len(rule_at) == 1, "Expected exactly one mcpplibs.mplugin.slint build dependency" lines[rule_at[0]] = rule_line manifest.write_text("\n".join(lines) + "\n") if args.index: