From cc8844671773e2fbfe0c17fdf504ff2bed769413 Mon Sep 17 00:00:00 2001 From: edouard Date: Thu, 8 Dec 2022 09:07:45 +0100 Subject: [PATCH] deps: make libc optional libc dependency is only use by the lianad binary it is not needed for liana-gui. This commit makes the dependency optional by introducing a new default feature named daemon. liana/src/daemonize.rs is still compiling because the feature daemon is marked as required for the lianad binary. --- Cargo.toml | 7 ++++--- src/lib.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9258c5c8..f0834b82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ exclude = [".github/", ".cirrus.yml", "tests/", "test_data/", "contrib/", "pypr [[bin]] name = "lianad" path = "src/bin/daemon.rs" -required-features = ["jsonrpc_server"] +required-features = ["jsonrpc_server", "daemon"] [[bin]] name = "liana-cli" @@ -20,8 +20,9 @@ path = "src/bin/cli.rs" required-features = ["jsonrpc_server"] [features] -default = ["jsonrpc_server"] +default = ["jsonrpc_server", "daemon"] jsonrpc_server = [] +daemon = ["libc"] [dependencies] # For managing transactions (it re-exports the bitcoin crate) @@ -52,7 +53,7 @@ rusqlite = { version = "0.26.3", features = ["bundled", "unlock_notify"] } jsonrpc = "0.12" # Used for daemonization -libc = "0.2" +libc = { version = "0.2", optional = true } # Used for PSBTs base64 = "0.13" diff --git a/src/lib.rs b/src/lib.rs index bee7934d..dabc616f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ mod bitcoin; pub mod commands; pub mod config; -#[cfg(unix)] +#[cfg(all(unix, feature = "daemon"))] mod daemonize; mod database; pub mod descriptors; @@ -381,7 +381,7 @@ impl DaemonHandle { // If we are on a UNIX system and they told us to daemonize, do it now. // NOTE: it's safe to daemonize now, as we don't carry any open DB connection // https://www.sqlite.org/howtocorrupt.html#_carrying_an_open_database_connection_across_a_fork_ - #[cfg(unix)] + #[cfg(all(unix, feature = "daemon"))] if config.daemon { log::info!("Daemonizing"); let log_file = data_dir.as_path().join("log");