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.
This commit is contained in:
edouard 2022-12-08 09:07:45 +01:00
parent 1d6a34e910
commit cc88446717
2 changed files with 6 additions and 5 deletions

View File

@ -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"

View File

@ -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");