Skip to content

Commit

Permalink
nom_mangle in lib removed
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Dec 4, 2023
1 parent 5df923c commit 4439ce3
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 57 deletions.
26 changes: 13 additions & 13 deletions DEFAULT_CONFIG.json5
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,18 @@
// },
// },

///// Plugin configuration example using `__config__` property
// plugins: {
// rest: {
// __config__: "./plugins/zenoh-plugin-rest/config.json5",
// },
// storage_manager: {
// __config__: "./plugins/zenoh-plugin-storage-manager/config.json5",
// },
// not_found: {
// },
// example: {
// },
//},
/// Plugin configuration example using `__config__` property
plugins: {
rest: {
__config__: "./plugins/zenoh-plugin-rest/config.json5",
},
storage_manager: {
__config__: "./plugins/zenoh-plugin-storage-manager/config.json5",
},
not_found: {
},
example: {
},
},

}
2 changes: 1 addition & 1 deletion plugins/example-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ publish = false

[features]
default = ["no_mangle"]
no_mangle = ["zenoh-plugin-trait/no_mangle"]
no_mangle = []

[lib]
# When auto-detecting the "example" plugin, `zenohd` will look for a dynamic library named "zenoh_plugin_example"
Expand Down
2 changes: 2 additions & 0 deletions plugins/zenoh-backend-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

//! ⚠️ WARNING ⚠️
//!
//! TODO: The example is outdated, rewrite it
//!
//! This crate should be considered unstable, as in we might change the APIs anytime.
//!
//! This crate provides the traits to be implemented by a zenoh backend library:
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ description = "The zenoh REST plugin"

[features]
default = ["no_mangle"]
no_mangle = ["zenoh-plugin-trait/no_mangle"]
no_mangle = []

[lib]
name = "zenoh_plugin_rest"
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-storage-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ description = "The zenoh storages plugin."

[features]
default = ["no_mangle"]
no_mangle = ["zenoh-plugin-trait/no_mangle"]
no_mangle = []

[lib]
name = "zenoh_plugin_storage_manager"
Expand Down
4 changes: 0 additions & 4 deletions plugins/zenoh-plugin-trait/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ description = { workspace = true }
[lib]
name = "zenoh_plugin_trait"

[features]
default = ["no_mangle"]
no_mangle = []

[dependencies]
libloading = { workspace = true }
log = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-trait/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ use zenoh_util::concat_enabled_features;

pub const FEATURES: &str = concat_enabled_features!(
prefix = "zenoh-plugin-trait",
features = ["default", "no_mangle"]
features = ["default"]
);
64 changes: 28 additions & 36 deletions plugins/zenoh-plugin-trait/src/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,41 +199,33 @@ impl<StartArgs, Instance> PluginVTable<StartArgs, Instance> {
}
}

pub use no_mangle::*;
#[cfg(feature = "no_mangle")]
pub mod no_mangle {
/// This macro will add a non-mangled functions which provides plugin version and loads it if feature `no_mangle` is enabled (which it is by default).
#[macro_export]
macro_rules! declare_plugin {
($ty: path) => {
#[no_mangle]
fn get_plugin_loader_version() -> $crate::PluginLoaderVersion {
$crate::PLUGIN_LOADER_VERSION
}

#[no_mangle]
fn get_compatibility() -> $crate::Compatibility {
$crate::Compatibility::with_plugin_version::<
<$ty as $crate::Plugin>::StartArgs,
<$ty as $crate::Plugin>::Instance,
$ty,
>()
}

#[no_mangle]
fn load_plugin() -> $crate::PluginVTable<
/// This macro will add a non-mangled functions which provides plugin version and loads it if feature `no_mangle` is enabled in the destination crate.
#[macro_export]
macro_rules! declare_plugin {
($ty: path) => {
#[cfg(feature = "no_mangle")]
#[no_mangle]
fn get_plugin_loader_version() -> $crate::PluginLoaderVersion {
$crate::PLUGIN_LOADER_VERSION
}

#[cfg(feature = "no_mangle")]
#[no_mangle]
fn get_compatibility() -> $crate::Compatibility {
$crate::Compatibility::with_plugin_version::<
<$ty as $crate::Plugin>::StartArgs,
<$ty as $crate::Plugin>::Instance,
> {
$crate::PluginVTable::new::<$ty>()
}
};
}
}
#[cfg(not(feature = "no_mangle"))]
pub mod no_mangle {
#[macro_export]
macro_rules! declare_plugin {
($ty: path) => {};
}
}
$ty,
>()
}

#[cfg(feature = "no_mangle")]
#[no_mangle]
fn load_plugin() -> $crate::PluginVTable<
<$ty as $crate::Plugin>::StartArgs,
<$ty as $crate::Plugin>::Instance,
> {
$crate::PluginVTable::new::<$ty>()
}
};
}

0 comments on commit 4439ce3

Please sign in to comment.