Skip to content

Commit

Permalink
Merge pull request #32 from eclipse-zenoh/simplified_load_plugin
Browse files Browse the repository at this point in the history
updated to new plugin API
  • Loading branch information
milyin authored Feb 22, 2024
2 parents 551de06 + 0b6dcc7 commit c24c0e5
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 83 deletions.
54 changes: 29 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 3 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,8 @@ Then, you may clone the repository on your machine:
```bash
$ git clone https://github.com/eclipse-zenoh/zenoh-plugin-mqtt.git
$ cd zenoh-plugin-mqtt
$ cargo build --release
```

> :warning: **WARNING** :warning: : On Windows and Linux, don't use `cargo build` command without specifying a package with `-p`. Building both `zenoh-plugin-mqtt` (plugin library) and `zenoh-bridge-mqtt` (standalone executable) together will lead to a `multiple definition of `load_plugin'` error at link time. See [#19](https://github.com/eclipse-zenoh/zenoh-plugin-mqtt/issues/19#issuecomment-1754742678) for explanations.
You can then choose between building the zenoh bridge for MQTT:
- as a plugin library that can be dynamically loaded by the zenoh router (`zenohd`):
```bash
$ cargo build --release -p zenoh-plugin-mqtt
```
The plugin shared library (`*.so` on Linux, `*.dylib` on Mac OS, `*.dll` on Windows) will be generated in the `target/release` subdirectory.

- or as a standalone executable binary:
```bash
$ cargo build --release -p zenoh-bridge-mqtt
```
The **`zenoh-bridge-mqtt`** binary will be generated in the `target/release` sub-directory.
The standalone executable binary `zenoh-bridge-mqtt` and a plugin shared library (`*.so` on Linux, `*.dylib` on Mac OS, `*.dll` on Windows) to be dynamically
loaded by the zenoh router `zenohd` will be generated in the `target/release` subdirectory.
10 changes: 7 additions & 3 deletions zenoh-bridge-mqtt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use clap::{App, Arg};
use std::str::FromStr;
use zenoh::config::{Config, ModeDependentValue};
use zenoh::prelude::*;
use zenoh_plugin_trait::Plugin;

macro_rules! insert_json5 {
($config: expr, $args: expr, $key: expr, if $name: expr) => {
Expand All @@ -36,8 +37,8 @@ macro_rules! insert_json5 {

fn parse_args() -> Config {
let app = App::new("zenoh bridge for MQTT")
.version(zenoh_plugin_mqtt::GIT_VERSION)
.long_version(zenoh_plugin_mqtt::LONG_VERSION.as_str())
.version(zenoh_plugin_mqtt::MqttPlugin::PLUGIN_VERSION)
.long_version(zenoh_plugin_mqtt::MqttPlugin::PLUGIN_LONG_VERSION)
//
// zenoh related arguments:
//
Expand Down Expand Up @@ -168,7 +169,10 @@ r#"-w, --generalise-pub=[String]... 'A list of key expression to use for gener
#[async_std::main]
async fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("z=info")).init();
log::info!("zenoh-bridge-mqtt {}", *zenoh_plugin_mqtt::LONG_VERSION);
log::info!(
"zenoh-bridge-mqtt {}",
zenoh_plugin_mqtt::MqttPlugin::PLUGIN_LONG_VERSION
);

let config = parse_args();
let rest_plugin = config.plugin("rest").is_some();
Expand Down
2 changes: 1 addition & 1 deletion zenoh-plugin-mqtt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ crate-type = ["cdylib", "rlib"]

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

[dependencies]
Expand Down
Loading

0 comments on commit c24c0e5

Please sign in to comment.