From 9bca19399ce345ee8a524ae5945a1d42189516c5 Mon Sep 17 00:00:00 2001 From: Riccardo Mazzarini Date: Mon, 9 Oct 2023 23:37:28 +0200 Subject: [PATCH] libuv: update to `1.46.0` on Neovim 0.9 and nightly --- crates/nvim-oxi/Cargo.toml | 8 +++----- crates/oxi-libuv/Cargo.toml | 7 ++++++- crates/oxi-libuv/src/async.rs | 3 +-- crates/oxi-libuv/src/handle.rs | 3 +-- crates/oxi-libuv/src/lib.rs | 4 ++++ crates/oxi-libuv/src/loop.rs | 3 ++- crates/oxi-libuv/src/timer.rs | 3 +-- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/crates/nvim-oxi/Cargo.toml b/crates/nvim-oxi/Cargo.toml index d87b4726..b98b657c 100644 --- a/crates/nvim-oxi/Cargo.toml +++ b/crates/nvim-oxi/Cargo.toml @@ -14,18 +14,16 @@ features = ["neovim-0-9", "libuv", "mlua", "test"] rustdoc-args = ["--cfg", "docsrs"] [features] -neovim-0-8 = ["oxi-api/neovim-0-8"] -neovim-0-9 = ["oxi-api/neovim-0-9"] -neovim-nightly = ["oxi-api/neovim-nightly"] +neovim-0-8 = ["oxi-api/neovim-0-8", "oxi-libuv/use-1-44"] +neovim-0-9 = ["oxi-api/neovim-0-9", "oxi-libuv/use-1-46"] +neovim-nightly = ["oxi-api/neovim-nightly", "oxi-libuv/use-1-46"] -# diagnostic = ["oxi-diagnostic"] libuv = ["oxi-libuv"] mlua = ["dep:mlua"] test = ["oxi-macros/test", "miniserde"] [dependencies] oxi-api = { workspace = true } -# oxi-diagnostic = { workspace = true } oxi-libuv = { version = "0.3.0", path = "../oxi-libuv", optional = true } oxi-luajit = { workspace = true } oxi-macros = { workspace = true } diff --git a/crates/oxi-libuv/Cargo.toml b/crates/oxi-libuv/Cargo.toml index ccbb1c0a..6ff9e99b 100644 --- a/crates/oxi-libuv/Cargo.toml +++ b/crates/oxi-libuv/Cargo.toml @@ -7,9 +7,14 @@ repository.workspace = true documentation.workspace = true license.workspace = true +[features] +use-1-44 = ["libuv-sys2-1-44"] +use-1-46 = ["libuv-sys2-1-46"] + [dependencies] oxi-luajit = { workspace = true } -libuv-sys2 = "1.44" +libuv-sys2-1-44 = { package = "libuv-sys2", version = "1.44.2", optional = true } +libuv-sys2-1-46 = { package = "libuv-sys2", version = "1.46.0", optional = true } once_cell = "1.17" thiserror = "1.0" diff --git a/crates/oxi-libuv/src/async.rs b/crates/oxi-libuv/src/async.rs index f91e171c..98fcccc7 100644 --- a/crates/oxi-libuv/src/async.rs +++ b/crates/oxi-libuv/src/async.rs @@ -1,7 +1,6 @@ use std::error::Error as StdError; -use libuv_sys2::{self as ffi, uv_async_t}; - +use crate::libuv_sys2::{self as ffi, uv_async_t}; use crate::{Error, Handle}; type Callback = Box Result<(), Box> + 'static>; diff --git a/crates/oxi-libuv/src/handle.rs b/crates/oxi-libuv/src/handle.rs index 985eb94b..55b98445 100644 --- a/crates/oxi-libuv/src/handle.rs +++ b/crates/oxi-libuv/src/handle.rs @@ -2,8 +2,7 @@ use std::alloc::{self, Layout}; use std::ffi::c_void; use std::marker::PhantomData; -use libuv_sys2::{self as ffi, uv_handle_t, uv_loop_t}; - +use crate::libuv_sys2::{self as ffi, uv_handle_t, uv_loop_t}; use crate::{Error, Result}; /// TODO: docs diff --git a/crates/oxi-libuv/src/lib.rs b/crates/oxi-libuv/src/lib.rs index 8c6578c8..9a7d846a 100644 --- a/crates/oxi-libuv/src/lib.rs +++ b/crates/oxi-libuv/src/lib.rs @@ -7,6 +7,10 @@ mod timer; pub use error::Error; use error::Result; use handle::Handle; +#[cfg(feature = "use-1-44")] +use libuv_sys2_1_44 as libuv_sys2; +#[cfg(feature = "use-1-46")] +use libuv_sys2_1_46 as libuv_sys2; pub use r#async::AsyncHandle; pub use r#loop::init; use r#loop::with_loop; diff --git a/crates/oxi-libuv/src/loop.rs b/crates/oxi-libuv/src/loop.rs index c198280e..0cbb7a11 100644 --- a/crates/oxi-libuv/src/loop.rs +++ b/crates/oxi-libuv/src/loop.rs @@ -1,7 +1,8 @@ -use libuv_sys2::uv_loop_t; use once_cell::unsync::OnceCell; use oxi_luajit::ffi::lua_State; +use crate::libuv_sys2::uv_loop_t; + thread_local! { static LOOP: OnceCell<*mut uv_loop_t> = OnceCell::new(); } diff --git a/crates/oxi-libuv/src/timer.rs b/crates/oxi-libuv/src/timer.rs index a6f1fded..2484c721 100644 --- a/crates/oxi-libuv/src/timer.rs +++ b/crates/oxi-libuv/src/timer.rs @@ -1,8 +1,7 @@ use std::error::Error as StdError; use std::time::Duration; -use libuv_sys2::{self as ffi, uv_timer_t}; - +use crate::libuv_sys2::{self as ffi, uv_timer_t}; use crate::{Error, Handle}; pub(crate) type Callback = Box<