docs(plugin): rewrite architecture + template for the external-only model
OpenCADStudio ships no built-in plugins, so the spec and scaffold no longer describe the in-tree inventory path, demo_plugin, or the fictional Storm Sewer reference. The architecture doc now covers the external cdylib model end to end (ocs_plugin_api contract, export_plugin!, building + publishing per-platform releases, runtime loading, the marketplace + curated registry, the approach-B ABI caveat). The template becomes a standalone cdylib crate (Cargo.toml + src/lib.rs + release workflow) instead of an in-tree module. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
157412419e
commit
1175675c5e
10 changed files with 399 additions and 361 deletions
|
|
@ -1,31 +1,47 @@
|
|||
# Add-on plugin template
|
||||
# Open CAD Studio plugin template
|
||||
|
||||
Copy this folder to `src/modules/<your_module>/` and rename placeholders.
|
||||
A complete scaffold for an **external** Open CAD Studio add-on. A plugin is its
|
||||
own repository that builds a `cdylib`; the host loads it at runtime. Copy this
|
||||
folder into a new repo and rename the placeholders.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `Cargo.toml` | `cdylib` crate depending on `ocs_plugin_api` (`host` feature) |
|
||||
| `src/lib.rs` | manifest + `CadModule` ribbon + `BuiltinPlugin` + `export_plugin!` |
|
||||
| `plugin.toml` | metadata read by the host (mirrors the manifest) |
|
||||
| `.github/workflows/release.yml` | cross-builds the cdylib and publishes a release |
|
||||
| `PLUGIN.md` | your command reference + XDATA schemas |
|
||||
|
||||
## Quick start
|
||||
|
||||
1. Copy files into `src/modules/my_plugin/`.
|
||||
2. Replace `MY_PLUGIN`, `my_plugin`, `opencad.my_plugin`, `MP_` throughout.
|
||||
3. Add `pub mod my_plugin;` to `src/modules/mod.rs`.
|
||||
4. `cargo build` — ribbon tab and commands register automatically.
|
||||
1. Copy this folder into a new repository.
|
||||
2. Rename `my-plugin` / `My Plugin` / `opencad.my_plugin` / `my_plugin` / `MP_`
|
||||
throughout (`Cargo.toml`, `src/lib.rs`, `plugin.toml`, the workflow `asset:`
|
||||
names), keeping `plugin.toml` and the `MANIFEST` in sync.
|
||||
3. `cargo build` to check it compiles.
|
||||
|
||||
## Required files
|
||||
## Test locally
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `plugin.toml` | Metadata (QGIS-style); excludes dir from `build.rs` ribbon scan |
|
||||
| `manifest.rs` | Compile-time `PluginManifest` — keep in sync with `plugin.toml` |
|
||||
| `register.rs` | `inventory::submit!(PluginRegistration { … })` only |
|
||||
| `plugin.rs` | Thin `BuiltinPlugin` impl |
|
||||
| `dispatch.rs` | All command handlers |
|
||||
| `mod.rs` | `CadModule` ribbon + `CommandRegistration` for autocomplete |
|
||||
| `PLUGIN.md` | XDATA schemas and command reference |
|
||||
```sh
|
||||
cargo build --release
|
||||
mkdir -p "<config>/OpenCADStudio/plugins/opencad.my_plugin"
|
||||
cp target/release/*my_plugin*.so "<config>/OpenCADStudio/plugins/opencad.my_plugin/"
|
||||
cp plugin.toml "<config>/OpenCADStudio/plugins/opencad.my_plugin/"
|
||||
```
|
||||
|
||||
## Optional
|
||||
Restart Open CAD Studio: the ribbon tab appears and `MP_` commands route to your
|
||||
plugin. (`<config>` = `%APPDATA%` / `~/Library/Application Support` /
|
||||
`$XDG_CONFIG_HOME`.)
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `state.rs` | Per-document tab state via `host.ensure_plugin_state(PLUGIN_ID, …)` |
|
||||
| `crates/my_engine/` | Headless domain logic (no iced/acadrust) |
|
||||
## Publish
|
||||
|
||||
See `docs/plugin-architecture.md` for the full spec.
|
||||
Push a `v*` tag — the workflow builds the cdylib on Linux/Windows/macOS and
|
||||
uploads each binary plus `plugin.toml` to a GitHub Release. Users install it from
|
||||
the **Plugin Manager** by linking your `owner/repo`, or — once your repo is added
|
||||
to [`plugins/registry.json`](https://github.com/HakanSeven12/OpenCADStudio/blob/main/plugins/registry.json)
|
||||
via PR — straight from *Available plugins*.
|
||||
|
||||
> The binary must be built with the same toolchain and `ocs_plugin_api` version
|
||||
> as the host (approach B). See `docs/plugin-architecture.md`.
|
||||
|
|
|
|||
Loading…
Reference in a new issue