Fix 5: Allow backward-compatibility and add plugin-template-v2
This commit is contained in:
parent
2b898d6f22
commit
d0003534a0
12 changed files with 568 additions and 60 deletions
|
|
@ -41,7 +41,9 @@ pub mod shm;
|
|||
#[cfg(feature = "host")]
|
||||
pub mod runner;
|
||||
|
||||
pub use manifest::{ApiVersion, PluginManifest, API_VERSION, API_VERSION_MIN_SUPPORTED};
|
||||
pub use manifest::{
|
||||
host_accepts_plugin_version, ApiVersion, PluginManifest, API_VERSION, API_VERSION_MIN_SUPPORTED,
|
||||
};
|
||||
pub use ribbon::{CadModule, IconKind, ModuleEvent, RibbonGroup, RibbonItem, StyleKey, ToolDef};
|
||||
|
||||
#[cfg(feature = "host")]
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ impl ApiVersion {
|
|||
}
|
||||
}
|
||||
|
||||
/// True when a plugin built against `plugin_major` can be loaded by this host.
|
||||
/// The host supports majors from `API_VERSION_MIN_SUPPORTED` up to
|
||||
/// `API_VERSION`.
|
||||
pub fn host_accepts_plugin_version(plugin_major: u32) -> bool {
|
||||
plugin_major >= API_VERSION_MIN_SUPPORTED && plugin_major <= API_VERSION
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ unsafe fn load_plugin(path: &Path) -> Result<Box<dyn BuiltinPlugin>, Box<dyn std
|
|||
.get(b"ocs_plugin_api_version")
|
||||
.map_err(|_| "missing ocs_plugin_api_version symbol")?;
|
||||
let v = version();
|
||||
if v < crate::API_VERSION_MIN_SUPPORTED || v > crate::API_VERSION {
|
||||
if !crate::host_accepts_plugin_version(v) {
|
||||
return Err(format!(
|
||||
"API version {v} is incompatible (host supports {}-{})",
|
||||
crate::API_VERSION_MIN_SUPPORTED,
|
||||
|
|
|
|||
Loading…
Reference in a new issue