Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 65 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,39 +80,50 @@ jobs:
{ "os": "ubuntu-latest", "toolchain": "i686-unknown-linux-gnu", "name": "Linux GNU (32-bit)" },
# TODO: Add some more OS variants here.
]
channel: [stable, beta, nightly]
channel: [stable, nightly]
features: [all, default, none]
install-header: [true, false]

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Install WeeChat
if: runner.os == 'Linux'
run: |
sudo mkdir /root/.gnupg
sudo chmod 700 /root/.gnupg
sudo mkdir -p /usr/share/keyrings
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/weechat-archive-keyring.gpg --keyserver hkps://keys.openpgp.org --recv-keys 11E9DE8848F2B65222AA75B8D1820DB22A11534E
echo "deb [signed-by=/usr/share/keyrings/weechat-archive-keyring.gpg] https://weechat.org/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/weechat.list
echo "deb-src [signed-by=/usr/share/keyrings/weechat-archive-keyring.gpg] https://weechat.org/ubuntu jammy main" | sudo tee -a /etc/apt/sources.list.d/weechat.list
sudo apt-get update
sudo apt-get install weechat-dev
- name: Install WeeChat
if: runner.os == 'Linux' && matrix.install-header == true
run: |
sudo mkdir /root/.gnupg
sudo chmod 700 /root/.gnupg
sudo mkdir -p /usr/share/keyrings
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/weechat-archive-keyring.gpg --keyserver hkps://keys.openpgp.org --recv-keys 11E9DE8848F2B65222AA75B8D1820DB22A11534E
echo "deb [signed-by=/usr/share/keyrings/weechat-archive-keyring.gpg] https://weechat.org/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/weechat.list
echo "deb-src [signed-by=/usr/share/keyrings/weechat-archive-keyring.gpg] https://weechat.org/ubuntu jammy main" | sudo tee -a /etc/apt/sources.list.d/weechat.list
sudo apt-get update
sudo apt-get install weechat-dev

- if: ${{ matrix.target.toolchain == 'i686-unknown-linux-gnu' }}
run: sudo apt-get install libc6-dev-i386
- if: ${{ matrix.target.toolchain == 'i686-unknown-linux-gnu' }}
run: sudo apt-get install libc6-dev-i386

- run: rustup target add ${{ matrix.target.toolchain }}
- run: rustup target add ${{ matrix.target.toolchain }}

- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.channel }}
targets: ${{ matrix.target.toolchain }}
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.channel }}
targets: ${{ matrix.target.toolchain }}

- uses: Swatinem/rust-cache@v2

- uses: Swatinem/rust-cache@v2
- name: Test all features
if: matrix.features == 'all'
run: cargo test --target ${{ matrix.target.toolchain }} --all-features

- name: Test default features
if: matrix.features == 'default'
run: cargo test --target ${{ matrix.target.toolchain }}

- name: Test
run: cargo test --all-features --target ${{ matrix.target.toolchain }}
- name: Test no features
if: matrix.features == 'none'
run: cargo test --target ${{ matrix.target.toolchain }} --no-default-features

test-api:
name: Test Weechat API
Expand All @@ -135,42 +146,42 @@ jobs:
- v4.6.0
- v4.7.0
env:
WEECHAT_BUNDLED: 'no'
WEECHAT_PLUGIN_FILE: '${{ github.workspace }}/weechat-src/src/plugins/weechat-plugin.h'
WEECHAT_BUNDLED: "no"
WEECHAT_PLUGIN_FILE: "${{ github.workspace }}/weechat-src/src/plugins/weechat-plugin.h"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Checkout weechat API header
uses: actions/checkout@v4
with:
repository: 'weechat/weechat'
ref: ${{ matrix.version }}
path: 'weechat-src'
sparse-checkout: src/plugins/weechat-plugin.h
sparse-checkout-cone-mode: false
- name: Checkout weechat API header
uses: actions/checkout@v4
with:
repository: "weechat/weechat"
ref: ${{ matrix.version }}
path: "weechat-src"
sparse-checkout: src/plugins/weechat-plugin.h
sparse-checkout-cone-mode: false

- run: sudo apt -y update
- run: sudo apt -y install libclang-dev
- run: sudo apt -y update
- run: sudo apt -y install libclang-dev

- if: ${{ matrix.toolchain == 'i686-unknown-linux-gnu' }}
run: sudo apt-get install libc6-dev-i386
- if: ${{ matrix.toolchain == 'i686-unknown-linux-gnu' }}
run: sudo apt-get install libc6-dev-i386

- run: rustup target add ${{ matrix.toolchain }}
- run: rustup target add ${{ matrix.toolchain }}

- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
targets: ${{ matrix.toolchain }}
toolchain: stable
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
targets: ${{ matrix.toolchain }}
toolchain: stable

- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@v2

- name: Test
run: cargo test --all-features --target ${{ matrix.toolchain }}
- name: Test
run: cargo test --all-features --target ${{ matrix.toolchain }}

- name: Build
run: cargo build --all-features --target ${{ matrix.toolchain }}
- name: Build
run: cargo build --all-features --target ${{ matrix.toolchain }}

- name: Lint
run: cargo clippy --all-features --target ${{ matrix.toolchain }}
- name: Lint
run: cargo clippy --all-features --target ${{ matrix.toolchain }}
4 changes: 2 additions & 2 deletions crates/weechat-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "weechat-macro"
version = "0.4.0"
authors = ["Damir Jelić <poljar@termina.org.uk>"]
description = "Procedural macros for the weechat crate"
edition = "2018"
edition = "2021"
license = "MIT"
readme = "README.md"
repository = "https://github.com/poljar/rust-weechat"
Expand All @@ -13,7 +13,7 @@ proc-macro = true

[dependencies]
libc = "0.2.132"
syn = "1.0.99"
syn = "2.0.0"
proc-macro2 = "1.0.43"
quote = "1.0.21"

Expand Down
2 changes: 1 addition & 1 deletion crates/weechat-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Parse for WeechatPluginInfo {
input.parse::<syn::Token![,]>()?;

let args: Punctuated<WeechatVariable, syn::Token![,]> =
input.parse_terminated(WeechatVariable::parse)?;
input.parse_terminated(WeechatVariable::parse, syn::Token![,])?;
let mut variables = HashMap::new();

for arg in args.pairs() {
Expand Down
6 changes: 5 additions & 1 deletion crates/weechat-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ name = "weechat-sys"
version = "0.4.0"
authors = ["Damir Jelić <poljar@termina.org.uk>"]
description = "Rust low level API bindings for Weechat"
edition = "2018"
edition = "2021"
license = "MIT"
readme = "README.md"
repository = "https://github.com/poljar/rust-weechat"

[features]
default = []
vendor = []

[build-dependencies]
bindgen = "0.70.0"

Expand Down
40 changes: 21 additions & 19 deletions crates/weechat-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,28 @@ fn main() {

let plugin_file = env::var(WEECHAT_PLUGIN_FILE_ENV);

let bindings = if bundled {
println!("cargo::warning=Using vendored header");
build("src/weechat-plugin.h").expect("Unable to generate bindings")
} else {
match plugin_file {
Ok(file) => {
let path = PathBuf::from(file).canonicalize().expect("Can't canonicalize path");
println!("cargo::warning=Using system header");
build(path.to_str().unwrap_or_default()).unwrap_or_else(|_| {
panic!("Unable to generate bindings with the provided {:?}", path)
})
}
Err(_) => {
println!("cargo::warning=Using system header via wrapper.h");
let bindings = build("src/wrapper.h");
let bindings = plugin_file
.map(|file| {
let path = PathBuf::from(file);
path.canonicalize().unwrap_or(path)
})
.map(|path| {
println!("cargo::warning=Using system header with path: {path:?}");
build(path.to_str().unwrap_or_default())
})
.unwrap_or_else(|_| {
println!("cargo::warning=Using system header via wrapper.h");
build("src/wrapper.h")
});

match bindings {
Ok(b) => b,
Err(_) => build("src/weechat-plugin.h").expect("Unable to generate bindings"),
}
let bindings = match bindings {
Ok(b) => b,
Err(err) => {
if std::env::var("CARGO_FEATURE_VENDOR").is_ok() || bundled {
println!("cargo::warning=Using vendored header");
build("src/weechat-plugin.h").expect("Unable to generate bindings")
} else {
panic!("\n!!!!!\nUnable to build weechat-plugin bindings and vendored bindings are not enabled: {err}!!!!!\n");
}
}
};
Expand Down
16 changes: 11 additions & 5 deletions crates/weechat-sys/src/weechat-plugin.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* weechat-plugin.h - header to compile WeeChat plugins
*
* Copyright (C) 2003-2024 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2003-2025 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
Expand Down Expand Up @@ -74,7 +74,7 @@ struct t_weelist_item;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
#define WEECHAT_PLUGIN_API_VERSION "20240727-01"
#define WEECHAT_PLUGIN_API_VERSION "20250215-01"

/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
Expand Down Expand Up @@ -307,6 +307,8 @@ struct t_weechat_plugin
int upgrading; /* 1 if the plugin must load upgrade */
/* info on startup (if weechat is */
/* run with --upgrade) */
int unload_with_upgrade; /* 1 if the plugin is unloaded after */
/* /upgrade command */
struct t_hashtable *variables; /* plugin custom variables */
struct t_weechat_plugin *prev_plugin; /* link to previous plugin */
struct t_weechat_plugin *next_plugin; /* link to next plugin */
Expand Down Expand Up @@ -465,7 +467,7 @@ struct t_weechat_plugin
int (*util_version_number) (const char *version);

/* sorted lists */
struct t_weelist *(*list_new) ();
struct t_weelist *(*list_new) (void);
struct t_weelist_item *(*list_add) (struct t_weelist *weelist,
const char *data,
const char *where,
Expand Down Expand Up @@ -996,7 +998,7 @@ struct t_weechat_plugin
const void *close_callback_pointer,
void *close_callback_data);
struct t_gui_buffer *(*buffer_search) (const char *plugin, const char *name);
struct t_gui_buffer *(*buffer_search_main) ();
struct t_gui_buffer *(*buffer_search_main) (void);
void (*buffer_clear) (struct t_gui_buffer *buffer);
void (*buffer_close) (struct t_gui_buffer *buffer);
void (*buffer_merge) (struct t_gui_buffer *buffer,
Expand Down Expand Up @@ -1131,6 +1133,8 @@ struct t_weechat_plugin
const char *data, int position, int direction);
const char *(*completion_get_string) (struct t_gui_completion *completion,
const char *property);
void (*completion_set) (struct t_gui_completion *completion,
const char *property, const char *value);
void (*completion_list_add) (struct t_gui_completion *completion,
const char *word,
int nick_completion,
Expand Down Expand Up @@ -2202,6 +2206,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__position, __direction)
#define weechat_completion_get_string(__completion, __property) \
(weechat_plugin->completion_get_string)(__completion, __property)
#define weechat_completion_set(__completion, __property, __value) \
(weechat_plugin->completion_set)(__completion, __property, __value)
#define weechat_completion_list_add(__completion, __word, \
__nick_completion, __where) \
(weechat_plugin->completion_list_add)(__completion, __word, \
Expand Down Expand Up @@ -2384,4 +2390,4 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
}
#endif /* __cplusplus */

#endif /* WEECHAT_WEECHAT_PLUGIN_H */
#endif /* WEECHAT_WEECHAT_PLUGIN_H */
17 changes: 11 additions & 6 deletions crates/weechat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Damir Jelić <poljar@termina.org.uk>"]

repository = "https://github.com/poljar/rust-weechat/"
homepage = "https://github.com/poljar/rust-weechat/"
edition = "2018"
edition = "2021"

readme = "README.md"
description = "Weechat API bindings for Rust"
Expand All @@ -16,6 +16,8 @@ features = ["docs"]
rustdoc-args = ["--cfg", "feature=\"docs\""]

[features]
default = []

# Support to run futures on the Weechat main thread.
async = ["async-task", "pipe-channel", "futures", "async-trait"]

Expand All @@ -25,6 +27,9 @@ config_macro = ["paste", "strum"]
# Still unsound or experimental features will be hidden behind this flag.
unsound = []

# Include weechat-plugin.h vendored copy as a fallback
vendor = ["weechat-sys/vendor"]

docs = ["async", "unsound", "config_macro"]

[dependencies]
Expand All @@ -33,19 +38,19 @@ libc = "0.2.132"
backtrace = "0.3.66"
async-task = { version = "4.3.0", optional = true }
async-trait = { version = "0.1.57", optional = true }
pipe-channel = { version = "1.3.0", optional = true }
pipe-channel = { version = "1.3.1", optional = true, rev = "815078dce3c1a1c4ff3d1cdf6d386448108508c3", git = "https://github.com/panekj/pipe-channel.git" }
futures = { version = "0.3.24", optional = true }
paste = { version = "1.0.9", optional = true }
strum = { version = "0.24.1", optional = true }
strum = { version = "0.27.2", optional = true }

weechat-macro = { version = "0.4.0", path = "../weechat-macro" }
weechat-sys = { version = "0.4.0", path = "../weechat-sys" }

[dev-dependencies]
async-std = "1.12.0"
pipe-channel = "1.3.0"
strum = "0.24.1"
strum_macros = "0.24.3"
pipe-channel = { version = "1.3.1", rev = "815078dce3c1a1c4ff3d1cdf6d386448108508c3", git = "https://github.com/panekj/pipe-channel.git" }
strum = "0.27.2"
strum_macros = "0.27.2"
futures = "0.3.24"

[build-dependencies]
Expand Down
Loading