feat(plugin): load external cdylib plugins at runtime (phase 2)

Move BuiltinPlugin into ocs_plugin_api (host feature) so out-of-tree
crates can implement it, and add export_plugin! to emit the two C
symbols a cdylib exposes: ocs_plugin_api_version (checked first, so an
ABI-incompatible build never runs) and ocs_plugin_register -> boxed
BuiltinPlugin. The host loads every compatible package from the plugins
folder at startup via libloading (desktop only), keeps the library
resident for the session, and merges its ribbon tab + command dispatch
into the same paths as built-ins (honouring enable/disable). The Plugin
Manager shows external packages with a Loaded / incompatible status.

Approach B: the plugin hands back a boxed trait object, assuming a
matching toolchain + ocs_plugin_api version (the version symbol enforces
the latter). crates/ocs_example_plugin is the reference cdylib.

Part of the #100 extensibility epic (phase 2).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-17 14:48:56 +03:00
1 parent f6219a9609
commit 29c71be101
14 files changed
+402 -36

No files matched your search

+3 -1
View File
@@ -5,7 +5,7 @@ edition = "2021"
build = "build.rs"
[workspace]
members = ["crates/ocs_plugin_api"]
members = ["crates/ocs_plugin_api", "crates/ocs_example_plugin"]
# Embed the application icon into the Windows .exe so Explorer, the taskbar,
# the Start-menu tile and file-association entries show it (issue #107).
@@ -79,6 +79,8 @@ acadrust = { git = "https://github.com/HakanSeven12/acadrust", branch = "main" }
rayon = "1"
open = "5"
ureq = { version = "3", default-features = false, features = ["rustls"] }
# Runtime loading of external plugin cdylibs (phase 2, desktop only).
libloading = "0.8"
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"