diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7a27779..7675bdf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,7 +69,7 @@ jobs: - java - js - py - - luajit + - lua steps: - uses: arduino/setup-protoc@v3 with: diff --git a/Cargo.toml b/Cargo.toml index f5a1f49..4394369 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,20 +64,21 @@ napi-build = { version = "2.1", optional = true } pyo3-build-config = { version = "0.22", optional = true } [features] -default = [] +default = ["lua-jit", "py-abi3"] # extra async-trait = ["dep:async-trait"] serialize = ["dep:serde", "uuid/serde"] # special tests which require more setup test-e2e = [] # ffi -java = ["lazy_static", "jni", "tracing-subscriber", "jni-toolbox"] -js = ["napi-build", "tracing-subscriber", "napi", "napi-derive"] -py-noabi = ["pyo3", "tracing-subscriber", "pyo3-build-config"] -py = ["py-noabi", "pyo3/abi3-py38"] -lua = ["mlua-codemp-patch", "tracing-subscriber", "lazy_static", "serialize"] -lua54 =["lua", "mlua-codemp-patch/lua54"] -luajit = ["lua", "mlua-codemp-patch/luajit"] +java = ["dep:lazy_static", "dep:jni", "dep:tracing-subscriber", "dep:jni-toolbox"] +js = ["dep:napi-build", "dep:tracing-subscriber", "dep:napi", "dep:napi-derive"] +py = ["dep:pyo3", "dep:tracing-subscriber", "dep:pyo3-build-config"] +lua = ["serialize", "dep:mlua-codemp-patch", "dep:tracing-subscriber", "dep:lazy_static"] +# ffi variants +lua-jit = ["mlua-codemp-patch?/luajit"] +lua-54 = ["mlua-codemp-patch?/lua54"] +py-abi3 = ["pyo3?/abi3-py38"] [package.metadata.docs.rs] # enabled features when building on docs.rs diff --git a/build.rs b/build.rs index e305a3f..0ee4a1e 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,7 @@ #[cfg(feature = "js")] extern crate napi_build; -#[cfg(any(feature = "py", feature = "py-noabi"))] +#[cfg(feature = "py")] extern crate pyo3_build_config; /// The main method of the buildscript, required by some glue modules. @@ -11,7 +11,7 @@ fn main() { napi_build::setup(); } - #[cfg(any(feature = "py", feature = "py-noabi"))] + #[cfg(feature = "py")] { pyo3_build_config::add_extension_module_link_args(); } diff --git a/dist/lua/codemp-0.8.2-1.rockspec b/dist/lua/codemp-0.8.2-1.rockspec index 7013f9d..b03419d 100644 --- a/dist/lua/codemp-0.8.2-1.rockspec +++ b/dist/lua/codemp-0.8.2-1.rockspec @@ -29,6 +29,8 @@ description = { build = { type = "rust-mlua", modules = { "codemp" }, + default_features = false, + features = { "lua" }, target_path = "../..", include = { ["dist/lua/annotations.lua"] = "codemp-annotations.lua", diff --git a/src/api/change.rs b/src/api/change.rs index 60d28f2..bbce5fc 100644 --- a/src/api/change.rs +++ b/src/api/change.rs @@ -9,7 +9,7 @@ /// be provided every time. #[derive(Clone, Debug, Default)] #[cfg_attr(feature = "js", napi_derive::napi(object))] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass(get_all))] +#[cfg_attr(feature = "py", pyo3::pyclass(get_all))] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] pub struct BufferUpdate { /// Optional content hash after applying this change. @@ -51,7 +51,7 @@ pub struct BufferUpdate { /// ``` #[derive(Clone, Debug, Default)] #[cfg_attr(feature = "js", napi_derive::napi(object))] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass(get_all))] +#[cfg_attr(feature = "py", pyo3::pyclass(get_all))] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] pub struct TextChange { /// Range start of text change, as char indexes in buffer previous state. @@ -69,7 +69,7 @@ impl TextChange { } } -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pymethods)] +#[cfg_attr(feature = "py", pyo3::pymethods)] impl TextChange { /// Returns true if this [`TextChange`] deletes existing text. /// diff --git a/src/api/config.rs b/src/api/config.rs index dcea368..26f90f1 100644 --- a/src/api/config.rs +++ b/src/api/config.rs @@ -10,10 +10,7 @@ /// http{tls?'s':''}://{host}:{port} #[derive(Clone, Debug, Default)] #[cfg_attr(feature = "js", napi_derive::napi(object))] -#[cfg_attr( - any(feature = "py", feature = "py-noabi"), - pyo3::pyclass(get_all, set_all) -)] +#[cfg_attr(feature = "py", pyo3::pyclass(get_all, set_all))] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] pub struct Config { /// User identifier used to register, possibly your email. diff --git a/src/api/cursor.rs b/src/api/cursor.rs index 89ecd5e..6a96b42 100644 --- a/src/api/cursor.rs +++ b/src/api/cursor.rs @@ -1,13 +1,13 @@ //! ### Cursor //! Represents the position of a remote user's cursor. -#[cfg(any(feature = "py", feature = "py-noabi"))] +#[cfg(feature = "py")] use pyo3::prelude::*; /// An event that occurred about a user's cursor. #[derive(Clone, Debug, Default)] #[cfg_attr(feature = "js", napi_derive::napi(object))] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyclass)] +#[cfg_attr(feature = "py", pyclass)] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] // #[cfg_attr(feature = "py", pyo3(crate = "reexported::pyo3"))] pub struct Cursor { @@ -20,7 +20,7 @@ pub struct Cursor { /// A cursor selection span. #[derive(Clone, Debug, Default)] #[cfg_attr(feature = "js", napi_derive::napi(object))] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyclass)] +#[cfg_attr(feature = "py", pyclass)] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] // #[cfg_attr(feature = "py", pyo3(crate = "reexported::pyo3"))] pub struct Selection { diff --git a/src/api/event.rs b/src/api/event.rs index 8754778..d3c1654 100644 --- a/src/api/event.rs +++ b/src/api/event.rs @@ -6,7 +6,7 @@ use codemp_proto::workspace::workspace_event::Event as WorkspaceEventInner; /// Event in a [crate::Workspace]. #[derive(Debug, Clone)] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass)] +#[cfg_attr(feature = "py", pyo3::pyclass)] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] pub enum Event { diff --git a/src/api/user.rs b/src/api/user.rs index 28297fd..83c57f7 100644 --- a/src/api/user.rs +++ b/src/api/user.rs @@ -6,7 +6,7 @@ use uuid::Uuid; /// Represents a service user #[derive(Debug, Clone)] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass)] +#[cfg_attr(feature = "py", pyo3::pyclass)] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] pub struct User { /// User unique identifier, should never change. diff --git a/src/buffer/controller.rs b/src/buffer/controller.rs index 689f74c..62b6f6d 100644 --- a/src/buffer/controller.rs +++ b/src/buffer/controller.rs @@ -17,7 +17,7 @@ use crate::ext::IgnorableError; /// Each buffer controller internally tracks the last acknowledged state, remaining always in sync /// with the server while allowing to procedurally receive changes while still sending new ones. #[derive(Debug, Clone)] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass)] +#[cfg_attr(feature = "py", pyo3::pyclass)] #[cfg_attr(feature = "js", napi_derive::napi)] pub struct BufferController(pub(crate) Arc); diff --git a/src/client.rs b/src/client.rs index 17ddcbb..21e4662 100644 --- a/src/client.rs +++ b/src/client.rs @@ -22,7 +22,7 @@ use codemp_proto::{ session::{session_client::SessionClient, InviteRequest, WorkspaceRequest}, }; -#[cfg(any(feature = "py", feature = "py-noabi"))] +#[cfg(feature = "py")] use pyo3::prelude::*; /// A `codemp` client handle. @@ -32,7 +32,7 @@ use pyo3::prelude::*; /// A new [`Client`] can be obtained with [`Client::connect`]. #[derive(Debug, Clone)] #[cfg_attr(feature = "js", napi_derive::napi)] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyclass)] +#[cfg_attr(feature = "py", pyclass)] pub struct Client(Arc); #[derive(Debug)] diff --git a/src/cursor/controller.rs b/src/cursor/controller.rs index fd22375..ec26069 100644 --- a/src/cursor/controller.rs +++ b/src/cursor/controller.rs @@ -21,7 +21,7 @@ use codemp_proto::{ /// /// An unique [CursorController] exists for each active [crate::Workspace]. #[derive(Debug, Clone)] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass)] +#[cfg_attr(feature = "py", pyo3::pyclass)] #[cfg_attr(feature = "js", napi_derive::napi)] pub struct CursorController(pub(crate) Arc); diff --git a/src/ffi/mod.rs b/src/ffi/mod.rs index ce2f0f3..c594ee7 100644 --- a/src/ffi/mod.rs +++ b/src/ffi/mod.rs @@ -210,5 +210,5 @@ pub mod lua; pub mod js; /// python bindings, built with [pyo3] -#[cfg(any(feature = "py", feature = "py-noabi"))] +#[cfg(feature = "py")] pub mod python; diff --git a/src/workspace.rs b/src/workspace.rs index 1e7313e..4d0a788 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -41,7 +41,7 @@ use napi_derive::napi; /// Using a workspace handle, it's possible to receive events (user join/leave, filetree updates) /// and create/delete/attach to new buffers. #[derive(Debug, Clone)] -#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass)] +#[cfg_attr(feature = "py", pyo3::pyclass)] #[cfg_attr(feature = "js", napi)] pub struct Workspace(Arc);