rust-weechat icon indicating copy to clipboard operation
rust-weechat copied to clipboard

First trying with rust in weechat

Open fesnavarro opened this issue 4 years ago • 7 comments

Hello Guys, please don't kill me.

I cloned the repo and cargo build it to create those compiled files.

Should I mkdir /usr/share/weechat/rust than moving those compiled from weechat/src/*rs to there?

I've used some scripts with python and lua plugin, but I never added such a thing as a new language plugin before the scripts.

Everything else I've I got from apt, for instance, apt install weechat-python. So how to do it in manual?

Sorry for asking it here.

fesnavarro avatar Dec 14 '20 23:12 fesnavarro

You need to create a new crate, docs for this can be found in the official Rust docs: https://doc.rust-lang.org/cargo/guide/creating-a-new-project.html#creating-a-new-package. Make sure that the type will be --lib.

The examples in this repo are a good starting point, e.g. https://github.com/poljar/rust-weechat/blob/master/weechat/examples/sample/Cargo.toml. You'll need to replace the weechat dependency line to depend on a released version of this crate, that is replace the path with version = 0.4.0. As 0.4.0 is the latest release on crates.io.

poljar avatar Dec 15 '20 08:12 poljar

Okay, let me see if I'm doing it right.

These are the steps. "git clone" not this repo but "weechat-matrix-rs" instead cd weechat-matrix-rs && cargo new newname --lib cd newname && vim Cargo.toml replace dependence path with weechat = "0.4.0" "cargo build" it then use the target folder and copy it into .weechat / plugins?

fesnavarro avatar Dec 15 '20 11:12 fesnavarro

Are you trying to build weechat-matrix-rs or are you trying to create your own plugin?

poljar avatar Dec 15 '20 11:12 poljar

I'm trying to build weechat-matrix-rs but I got stuck here.

fesnavarro avatar Dec 15 '20 13:12 fesnavarro

In that case you need to point the env variable WEECHAT_PLUGIN_FILE to the weechat-plugin.h file you want to use and just call make install inside the weechat-matrix-rs repository.

$ WEECHAT_PLUGIN_FILE="/home/whatever/weechat-plugin.h" make install

poljar avatar Dec 15 '20 13:12 poljar

I've tried with and without quotes. Same result: make compiled without errors Then WEECHAT_PLUGIN_FILE="/thepathIfound/weechat-plugin.h" make install WEECHAT_PLUGIN_FILE='/thepathIfound/weechat-plugin.h' make install WEECHAT_PLUGIN_FILE=/thepathIfound/weechat-plugin.h make install

WeeChat 3.0 [compiled on Nov 11 2020 11:12:13] | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Error: API mismatch for plugin "/home/whatever/.weechat/plugins/matrix.so" (current API: "20201004-01", plugin API: "20200621-01"), failed to load | If plugin "matrix" is old/obsolete, you can delete this file. | script: 364 scripts for WeeChat 3.0 | Plugins loaded: alias, buflist, charset, exec, fifo, fset, irc, logger, lua, perl, python, relay, ruby, script, spell, │ | tcl, trigger, xfer

Shouldn't "Rust" appear in the list of plugins?

fesnavarro avatar Dec 15 '20 21:12 fesnavarro

I've tried with and without quotes. Same result: make compiled without errors Then WEECHAT_PLUGIN_FILE="/thepathIfound/weechat-plugin.h" make install WEECHAT_PLUGIN_FILE='/thepathIfound/weechat-plugin.h' make install WEECHAT_PLUGIN_FILE=/thepathIfound/weechat-plugin.h make install

The environment variable is a build time option, not a install time option.

$ WEECHAT_PLUGIN_FILE="/thepathIfound/weechat-plugin.h" cargo build && make install

We're using cargo directly since make will think there's nothing to do but cargo will correctly notice that the environment variable got changed.

WeeChat 3.0 [compiled on Nov 11 2020 11:12:13] | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Error: API mismatch for plugin "/home/whatever/.weechat/plugins/matrix.so" (current API: "20201004-01", plugin API: "20200621-01"), failed to load | If plugin "matrix" is old/obsolete, you can delete this file. | script: 364 scripts for WeeChat 3.0 | Plugins loaded: alias, buflist, charset, exec, fifo, fset, irc, logger, lua, perl, python, relay, ruby, script, spell, │ | tcl, trigger, xfer

Shouldn't "Rust" appear in the list of plugins?

No, the name of the plugin is matrix. The Rust bindings are creating plugins that work without going through a language specific plugin.

poljar avatar Dec 18 '20 18:12 poljar