Skip to content

Commit 7ce039c

Browse files
committed
Make the jsonrpc module optional through a default feature
1 parent 767c38e commit 7ce039c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,9 @@ jobs:
3838
toolchain: ${{ matrix.toolchain }}
3939
override: true
4040
profile: minimal
41-
- name: Test on Rust ${{ matrix.toolchain }}
41+
- name: Test on Rust ${{ matrix.toolchain }} (only Windows)
42+
if: matrix.os == 'windows-latest'
43+
run: cargo test --verbose --no-default-features
44+
- name: Test on Rust ${{ matrix.toolchain }} (non Windows)
45+
if: matrix.os != 'windows-latest'
4246
run: cargo test --verbose --color always -- --nocapture

Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ exclude = [".github/", ".cirrus.yml", "tests/", "test_data/", "contrib/", "pypr
1212
[[bin]]
1313
name = "revaultd"
1414
path = "src/bin/daemon.rs"
15+
required-features = ["jsonrpc_server"]
1516

1617
[[bin]]
1718
name = "revault-cli"
1819
path = "src/bin/cli.rs"
20+
required-features = ["jsonrpc_server"]
21+
22+
[features]
23+
default = ["jsonrpc_server"]
24+
jsonrpc_server = ["jsonrpc-core", "jsonrpc-derive", "mio"]
1925

2026
[dependencies]
2127
revault_tx = { git = "https://github.com/revault/revault_tx", features = ["use-serde"] }
@@ -54,6 +60,6 @@ rusqlite = { version = "0.26.3", features = ["bundled", "unlock_notify"] }
5460
libc = "0.2.80"
5561

5662
# For the JSONRPC server
57-
jsonrpc-core = "15.1"
58-
jsonrpc-derive = "15.1"
59-
mio = { version = "0.7", features = ["default", "os-poll", "os-util", "uds"] }
63+
jsonrpc-core = { version = "15.1", optional = true }
64+
jsonrpc-derive = { version = "15.1", optional = true }
65+
mio = { version = "0.7", features = ["default", "os-poll", "os-util", "uds"], optional = true }

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub mod commands;
66
mod communication;
77
pub mod config;
88
mod database;
9-
#[cfg(not(windows))]
9+
#[cfg(all(not(windows), feature = "jsonrpc_server"))]
1010
mod jsonrpc;
1111
mod revaultd;
1212
mod sigfetcher;
@@ -146,8 +146,8 @@ impl DaemonControl {
146146
self.sigfetcher_conn.shutdown();
147147
}
148148

149-
// TODO: make it optional at compile time
150149
/// Start and bind the server to the configured UNIX socket
150+
#[cfg(all(not(windows), feature = "jsonrpc_server"))]
151151
pub fn rpc_server_setup(&self) -> Result<jsonrpc::server::UnixListener, io::Error> {
152152
let socket_file = self.revaultd.read().unwrap().rpc_socket_file();
153153
jsonrpc::server::rpcserver_setup(socket_file)
@@ -260,8 +260,8 @@ impl DaemonHandle {
260260
.expect("Joining sigfetcher thread");
261261
}
262262

263-
// TODO: make it optional at compilation time
264263
/// Start the JSONRPC server and listen for commands until we are stopped
264+
#[cfg(all(not(windows), feature = "jsonrpc_server"))]
265265
pub fn rpc_server(&self) -> Result<(), io::Error> {
266266
log::info!("Starting JSONRPC server");
267267

0 commit comments

Comments
 (0)