Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First trying with rust in weechat #30

Open
fesnavarro opened this issue Dec 14, 2020 · 7 comments
Open

First trying with rust in weechat #30

fesnavarro opened this issue Dec 14, 2020 · 7 comments

Comments

@fesnavarro
Copy link

fesnavarro commented Dec 14, 2020

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.

@poljar
Copy link
Owner

poljar commented Dec 15, 2020

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.

@fesnavarro
Copy link
Author

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?

@poljar
Copy link
Owner

poljar commented Dec 15, 2020

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

@fesnavarro
Copy link
Author

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

@poljar
Copy link
Owner

poljar commented Dec 15, 2020

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

@fesnavarro
Copy link
Author

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?

@poljar
Copy link
Owner

poljar commented Dec 18, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants