From d71503e4fd8c5405fcb1c8d8852d4a3002fcb0dc Mon Sep 17 00:00:00 2001 From: Nils Andreas Svee Date: Thu, 20 Aug 2026 12:01:07 +0700 Subject: [PATCH] fix(app): preserve featureless build support The shared with_shutdown_flag helper, and the AtomicBool/Arc/ install_signal_handler imports it uses, only exist when at least one applet feature (client, server, tui) is enabled. Gate them accordingly instead of leaving them unconditionally compiled, which broke `--no-default-features` workspace CI under -D warnings (unused function/dead-code). Also correct the README installation section: tui is already part of the default feature set, so an ordinary `cargo install` already produces irtt-tui alongside the other three binaries. Document a lightweight `--no-default-features --features client` install instead of the previous (incorrect) framing of tui as an opt-in extra, and fix the same gap in the binaries/features table. --- README.md | 20 +++++++++++--------- crates/irtt-app/src/entry.rs | 17 +++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 974cfe2..2fd7d69 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,14 @@ This installs: * `irtt-rs`, the canonical multi-applet dispatcher * `irtt-client`, the stream and text client +* `irtt-tui`, the terminal UI * `irtt-server`, the UDP server -To also install the optional terminal UI: +Each applet can also be built in isolation with `--no-default-features` plus +the applet's own feature. For example, a lightweight client-only install: ```sh -cargo install --path crates/irtt-app --features tui +cargo install --path crates/irtt-app --no-default-features --features client ``` ## Quick start @@ -311,13 +313,13 @@ synchronous callers. Callers that already own Tokio can drive ## Binaries and features -| Build | Binaries | -| ----------------------------------------- | ------------------------------------------------- | -| `--no-default-features` | `irtt-rs` | -| `--no-default-features --features server` | `irtt-rs`, `irtt-server` | -| Default features | `irtt-rs`, `irtt-client`, `irtt-server` | -| `--features tui` | `irtt-rs`, `irtt-client`, `irtt-server`, `irtt-tui` | -| `--all-features` | `irtt-rs`, `irtt-client`, `irtt-server`, `irtt-tui` | +| Build | Binaries | +| -------------------------------------------- | --------------------------------------------------- | +| `--no-default-features` | `irtt-rs` | +| `--no-default-features --features client` | `irtt-rs`, `irtt-client` | +| `--no-default-features --features server` | `irtt-rs`, `irtt-server` | +| `--no-default-features --features tui` | `irtt-rs`, `irtt-tui` | +| Default features (or `--all-features`) | `irtt-rs`, `irtt-client`, `irtt-tui`, `irtt-server` | `irtt-client` requires the `client` feature, `irtt-server` the `server` feature, and `irtt-tui` the `tui` feature. The `irtt-rs` dispatcher is always built, and diff --git a/crates/irtt-app/src/entry.rs b/crates/irtt-app/src/entry.rs index 6615fb0..10fac74 100644 --- a/crates/irtt-app/src/entry.rs +++ b/crates/irtt-app/src/entry.rs @@ -1,14 +1,10 @@ -use std::{ - env, - ffi::OsString, - process::ExitCode, - sync::{atomic::AtomicBool, Arc}, -}; +#[cfg(any(feature = "client", feature = "server", feature = "tui"))] +use std::sync::{atomic::AtomicBool, Arc}; +use std::{env, ffi::OsString, process::ExitCode}; -use crate::{ - applet::{dispatch_from_argv, AppletDispatch, RequestedApplet}, - signal::install_signal_handler, -}; +use crate::applet::{dispatch_from_argv, AppletDispatch, RequestedApplet}; +#[cfg(any(feature = "client", feature = "server", feature = "tui"))] +use crate::signal::install_signal_handler; /// Entry point for the `irtt-rs` multicall dispatcher binary. /// @@ -81,6 +77,7 @@ fn run_dispatcher_from_env() -> Result<(), Box> { /// Installs the shutdown signal handler shared by every applet and hands the /// resulting flag to `f`. +#[cfg(any(feature = "client", feature = "server", feature = "tui"))] fn with_shutdown_flag( f: impl FnOnce(&AtomicBool) -> Result<(), Box>, ) -> Result<(), Box> {