[features]
default = ["runtime_completion_gen", "comptime_completion_gen", "comptime_manpage_gen"]
runtime_completion_gen = ["dep:clap_complete",]
comptime_completion_gen = ["dep:clap_complete"]
comptime_manpage_gen = ["dep:clap_mangen"]
[dependencies]
anyhow = "1.0.0"
clap = { version = "4.0.0", features = ["derive", "help"] }
clap_complete = { version = "4.0.0", optional = true }
ignore = "0.4.25"
[build-dependencies]
clap = { version = "4.0.0", features = ["derive"] }
clap_complete = { version = "4.0.0", optional = true }
clap_mangen = { version = "0.2.31", optional = true }
The features that start with comptime, as their name suggest, happen at comp time in build.rs, they generate shell completions and manpages for my cli utility, thus they depend only at build time to their respective dependencies, but there seems no way to specify this.
Does anyone know if there is a way to specify build deps for a feature?
You must log in or register to comment.
I don’t understand the problem.
cargo new tt-build cd tt-build cargo new --lib opt-dep echo 'pub const NAME: &str = "opt-dep";' > opt-dep/src/lib.rs// build.rs fn main() { #[cfg(feature = "opt_dep_b_ft")] println!("cargo:warning={}", opt_dep::NAME); #[cfg(not(feature = "opt_dep_b_ft"))] println!("cargo:warning=none"); }// src/main.rs fn main() { #[cfg(feature = "opt_dep_r_ft")] println!("Hello with {}", opt_dep::NAME); #[cfg(not(feature = "opt_dep_r_ft"))] println!("Hello with none"); }# Cargo.toml [package] name = "tt-build" version = "0.1.0" edition = "2024" [features] default = ["opt_dep_b_ft", "opt_dep_r_ft"] opt_dep_b_ft= ["dep:opt-dep"] opt_dep_r_ft= ["dep:opt-dep"] [dependencies] opt-dep = { path = "./opt-dep", optional = true } [build-dependencies] opt-dep = { path = "./opt-dep", optional = true }% cargo run --no-default-features 2>&1 | rg 'Hello|warn' warning: tt-build@0.1.0: none Hello with none% cargo run 2>&1 | rg 'Hello|warn' warning: tt-build@0.1.0: opt-dep Hello with opt-dep% cargo run --no-default-features --features=opt_dep_b_ft 2>&1 | rg 'Hello|warn' warning: tt-build@0.1.0: opt-dep Hello with none% cargo run --no-default-features --features=opt_dep_r_ft 2>&1 | rg 'Hello|warn' warning: tt-build@0.1.0: none Hello with opt-dep

