|
| 1 | +# Build plugins: `<owner>.mplugin.<name>` |
| 2 | + |
| 3 | +A **build plugin** is a package whose modules a project's `build.mcpp` imports |
| 4 | +(`host-module`): code generators, tool wrappers, rule sets. This page is the |
| 5 | +naming and layout rule for them; the design record is |
| 6 | +`.agents/docs/2026-11-21-mcpp-build-plugin-naming-plan.md`. |
| 7 | + |
| 8 | +[简体中文](zh/build-plugins.md) |
| 9 | + |
| 10 | +## One name, three spellings |
| 11 | + |
| 12 | +A build plugin's id is `<owner>.mplugin.<name>`. Its module and its C++ |
| 13 | +namespace are that id: |
| 14 | + |
| 15 | +| Spelling | Form | Example | |
| 16 | +|---|---|---| |
| 17 | +| package (namespace + name) | `<owner>.mplugin` + `<name>` | `mcpplibs.mplugin.slint` | |
| 18 | +| module | the id; sub-modules `<id>.<sub>` | `mcpplibs.mplugin.slint` | |
| 19 | +| C++ namespace | the id with `::` | `mcpplibs::mplugin::slint` | |
| 20 | + |
| 21 | +```cpp |
| 22 | +// build.mcpp |
| 23 | +import mcpp; |
| 24 | +import mcpplibs.mplugin.slint; |
| 25 | +int main() { |
| 26 | + mcpplibs::mplugin::slint::options o; |
| 27 | + o.sources = {"ui/app.slint"}; |
| 28 | + return mcpplibs::mplugin::slint::compile(o) ? 0 : 1; |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +`mplugin` is the kind segment, as `mwrap` is for wrappers |
| 33 | +(`mcpplibs.mwrap.slint` is the wrapper, `mcpplibs.mplugin.slint` its build |
| 34 | +plugin). Because the namespace is `<owner>::mplugin::<name>` and not |
| 35 | +`<owner>::mcpp::<name>`, code inside a plugin writes the engine as `mcpp::…` |
| 36 | +and nothing shadows it. |
| 37 | + |
| 38 | +Rules: |
| 39 | + |
| 40 | +1. `<owner>` and `<name>` are lower-case identifiers, `[a-z][a-z0-9_]*`: words |
| 41 | + are joined with `_`, never `-` (a module name needs an identifier; |
| 42 | + `mcpplibs.mwrap.godot_cpp` is the same rule). |
| 43 | +2. `<owner>` is who maintains the package. `mcpplibs` is for packages the |
| 44 | + mcpplibs organization maintains; anyone else uses their own name. |
| 45 | +3. `<owner>` is not `mcpp`, not one of the mcpp project's reserved names |
| 46 | + (`core`, `plugins`, `deps`, `rules`, `dist`, `tools`, `platforms`) and not a |
| 47 | + kind segment (`mwrap`, `mplugin`). A new official package name joins the |
| 48 | + reserved names; the check that no owner already has it is part of adding it. |
| 49 | +4. The main interface module is exactly the id; every other module of the |
| 50 | + package starts with `<id>.`. |
| 51 | +5. A package whose first segment is `mcpp` is maintained by the mcpp project |
| 52 | + and is not of this form (`mcpp.plugins`, `mcpp.platforms`). |
| 53 | +6. For a rule tied to one library, `<name>` is the library (`slint`, `grpc`, |
| 54 | + `protobuf`), with no `gen` or `-bind` suffix; several rules for one library |
| 55 | + are functions of one package. A general tool takes the tool's name |
| 56 | + (`clangtidy`). |
| 57 | + |
| 58 | +## Where a rule lives |
| 59 | + |
| 60 | +| Kind | Lives in | A project writes | |
| 61 | +|---|---|---| |
| 62 | +| tied to one library | the `rules/` sub-package of that library's `-m` repository; the descriptor says `mcpp = "*/rules/mcpp.toml"`; the wrapper's root manifest has `<id> = { path = "rules", host-module = true, reexport = true }` | only the wrapper | |
| 63 | +| a general tool | its own repository | `[build-dependencies] <id> = { version = "…", host-module = true }` | |
| 64 | +| engine-level, across ecosystems | the mcpp project's `mcpp.plugins` | a feature of `mcpp.plugins` | |
| 65 | + |
| 66 | +A rule package's own dependencies are in its `[dependencies]` (mcpp |
| 67 | +2026.10.11.1 and later). A feature that claims a file extension does not pass |
| 68 | +through `reexport`, so a rule tied to a library takes its inputs as `options` |
| 69 | +fields (`options::sources` of `mcpplibs.mplugin.slint`). |
| 70 | + |
| 71 | +## Index layout |
| 72 | + |
| 73 | +- The descriptor is `pkgs/mcpp/<full id>.lua`, one flat directory: the |
| 74 | + official `pkgs/mcpp/mcpp.plugins.lua`, the plugins |
| 75 | + `pkgs/mcpp/mcpplibs.mplugin.slint.lua`. The directory is the packages mcpp |
| 76 | + itself loads; the identity is what the descriptor declares (`namespace = |
| 77 | + "<owner>.mplugin"`, `name = "<name>"`), as for `pkgs/mwrap/`. The directory |
| 78 | + does not say what a package is: `mcpp.platforms` is platform data, not a |
| 79 | + plugin. |
| 80 | +- A descriptor whose namespace is `<owner>.mplugin` is in `pkgs/mcpp/`; a file |
| 81 | + in `pkgs/mcpp/` has namespace `mcpp` or `<owner>.mplugin` (lint |
| 82 | + `tests/check_mplugin_layout.lua`). |
| 83 | +- **A build plugin and its library are tested apart.** A plugin's member |
| 84 | + checks what `build.mcpp` can do with it (what the rule produces from a small |
| 85 | + input, that a generated module compiles, that an edited input regenerates); |
| 86 | + how the library behaves is the wrapper's member and installed-template |
| 87 | + check. A plugin tied to a library is tested at first through the wrapper's |
| 88 | + member (`tests/mwrap/…`); a plugin of its own gets `tests/mcpp/<owner>-<name>/`. |
| 89 | + |
| 90 | +## Versions |
| 91 | + |
| 92 | +Each package has its own line: the first release is the upstream version it is |
| 93 | +built for, a revision appends `.N`, and a tag never moves. A rule tied to a |
| 94 | +library is released with the wrapper: its descriptor row points at the |
| 95 | +wrapper's tag archive (same bytes, same sha256, GLOBAL and CN), and the rule's |
| 96 | +own `rules/mcpp.toml` version equals that row; it need not equal the wrapper's |
| 97 | +revision (`mcpplibs.mplugin.slint@1.19.0` is in the archive of |
| 98 | +`mcpplibs.mwrap.slint@1.19.0.3`). Such a descriptor has no `autoupdate`: its |
| 99 | +rows are added with the wrapper's. |
| 100 | + |
| 101 | +## Older packages |
| 102 | + |
| 103 | +Build rules published before this page keep working: `mcpplibs.slintgen`, |
| 104 | +`mcpplibs.grpcgen`, `mcpplibs.protogen`, `mcpplibs.clangtidy`, |
| 105 | +`mcpplibs.openkal-bind` follow the earlier rule (module |
| 106 | +`mcpp.<namespace>.<name>`, SPEC-007 §9) and are not wrong. Their descriptors |
| 107 | +and archives stay; a published row never changes. |
| 108 | + |
| 109 | +- A package moves to the new form when it next needs a new version: the new id |
| 110 | + is published in `pkgs/mcpp/`, the old descriptor is frozen (no `autoupdate`, |
| 111 | + `FROZEN: superseded by <id>` in its description) and gets no more versions. |
| 112 | + There is no forwarding module. |
| 113 | +- The id is the identity, so the old id cannot take the new module name: a |
| 114 | + project that wrote `x = "1"` would be moved to a new module name on update. |
| 115 | +- A project that wrote the old id keeps its versions and moves by changing the |
| 116 | + dependency name. |
| 117 | + |
| 118 | +| Old id | New id | Moved | |
| 119 | +|---|---|---| |
| 120 | +| `mcpplibs.slintgen` | `mcpplibs.mplugin.slint` | 1.19.0 | |
| 121 | +| `mcpplibs.grpcgen` | `mcpplibs.mplugin.grpc` | with grpc-m's next release | |
| 122 | +| `mcpplibs.protogen` | `mcpplibs.mplugin.protobuf` | with protobuf-m's next release | |
| 123 | +| `mcpplibs.clangtidy` | `mcpplibs.mplugin.clangtidy` | with its next release | |
| 124 | +| `mcpplibs.openkal-bind` | `mcpplibs.mplugin.openkal_bind` | with openkal's next release | |
| 125 | + |
| 126 | +`mcpplibs.rules-cuda` is a stub that points at `mcpp.rules.cuda`; it stays as |
| 127 | +it is. |
| 128 | + |
| 129 | +## Checks |
| 130 | + |
| 131 | +| Check | Where | |
| 132 | +|---|---| |
| 133 | +| namespace is not a reserved second segment of `mcpp.`; an owner is not `mcpp`, a reserved name or a kind segment | `tests/check_reserved_namespace.lua` | |
| 134 | +| layout: `<owner>.mplugin` ↔ `pkgs/mcpp/`; owner and name are identifiers | `tests/check_mplugin_layout.lua` | |
| 135 | +| a member's build prints no engine warning about a reserved module name | `tests/run_members.sh` | |
| 136 | +| the module is the package id | the rule's own repository CI (the index cannot read the archive's sources) | |
| 137 | + |
| 138 | +A build plugin runs code on the machine that builds: it is reviewed as a |
| 139 | +package that executes code. `mplugin` does not mean audited; who an owner is, |
| 140 | +and names that imitate `mcpplibs`, are for review. |
0 commit comments