Skip to content

Commit

Permalink
chore: add minimal compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
fioncat committed Jan 24, 2025
1 parent 9884396 commit aa59c05
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fn main() -> Result<(), Box<dyn Error>> {
env::var("TARGET").unwrap()
);

#[cfg(feature = "tray")]
tauri_build::build();

Ok(())
Expand Down
3 changes: 3 additions & 0 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod get;
mod put;
mod read;
mod server;
#[cfg(feature = "tray")]
mod tray;
mod version;
mod whoami;
Expand Down Expand Up @@ -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),
Expand All @@ -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!(),
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod secret;
mod server;
mod table;
mod time;
#[cfg(feature = "tray")]
mod tray;
mod types;

Expand Down

0 comments on commit aa59c05

Please sign in to comment.