diff --git a/Cargo.toml b/Cargo.toml index ba07b72..6877393 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,17 @@ readme = "README.md" repository = "https://github.com/fioncat/csync" description = "Share your clipboard between different devices" +[features] +# On some machines, particularly those running only server applications without a graphical +# interface environment, users need to install libwebkit to run csync, even though this +# library will never be used (as these machines won't utilize the tray functionality). +# Therefore, we provide a minimal compilation option that excludes GUI-related code from +# csync, resulting in a minimized version suitable for running on servers without GUI +# tools (tray). +# Minimal compilation: cargo build --release --locked --no-default-features +default = ["tray"] +tray = ["dep:tauri", "dep:tauri-plugin-shell", "dep:tauri-build"] + [dependencies] actix-web = { version = "4.9", features = ["openssl"] } aes-gcm = "0.10" @@ -36,8 +47,8 @@ serde = {version = "1.0", features = ["derive"] } serde_json = "1.0" sha2 = "0.10" shellexpand = "3.1" -tauri = { version = "2.2", features = ["tray-icon"] } -tauri-plugin-shell = "2.2" +tauri = { version = "2.2", features = ["tray-icon"], optional = true } +tauri-plugin-shell = { version = "2.2", optional = true } thiserror = "2.0" tokio = { version = "1.43", features = ["full"] } toml = "0.8" @@ -47,7 +58,7 @@ once_cell = "1.20" [build-dependencies] simple-error = "0.3" -tauri-build = { version = "2.0", features = [] } +tauri-build = { version = "2.0", features = [], optional = true } vergen = { version = "9.0", features = ["build", "rustc", "cargo", "si"] } [profile.release] diff --git a/build.rs b/build.rs index 74bd454..52ed041 100644 --- a/build.rs +++ b/build.rs @@ -76,6 +76,7 @@ fn main() -> Result<(), Box> { env::var("TARGET").unwrap() ); + #[cfg(feature = "tray")] tauri_build::build(); Ok(()) diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index 2d01a36..76715fb 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -7,6 +7,7 @@ mod get; mod put; mod read; mod server; +#[cfg(feature = "tray")] mod tray; mod version; mod whoami; @@ -41,6 +42,7 @@ pub enum Commands { Whoami(whoami::WhoamiArgs), Cani(cani::CaniArgs), Version(version::VersionArgs), + #[cfg(feature = "tray")] Tray(tray::TrayArgs), Server(server::ServerArgs), @@ -60,6 +62,7 @@ impl RunCommand for App { Commands::Whoami(args) => args.run().await, Commands::Cani(args) => args.run().await, Commands::Version(args) => args.run().await, + #[cfg(feature = "tray")] Commands::Tray(args) => args.run().await, Commands::Server(_) => unreachable!(), diff --git a/src/main.rs b/src/main.rs index 1a9ce26..0d03f9f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ mod secret; mod server; mod table; mod time; +#[cfg(feature = "tray")] mod tray; mod types;