Skip to content

Commit 3a99352

Browse files
committed
feat(build): gate build deps behind reload-ssh-algo feature
Replace RELOAD_SSH_ALGO env var with optional cargo feature. Makes anyhow and git2 (and openssl C bindings) optional build dependencies, only compiled when the feature is enabled. Closes #51
1 parent 102f11c commit 3a99352

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ cargo run --example print -- [config-path]
3232
cargo run --example client -- <host> [config-path]
3333

3434
# Regenerate default algorithms from OpenSSH source
35-
RELOAD_SSH_ALGO=1 cargo build
35+
cargo build --features reload-ssh-algo
3636
```
3737

3838
**Test environment setup:** Tests require `~/.ssh/config` to exist (can be empty).

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ ssh2 = "^0.9"
4040
tempfile = "^3"
4141

4242
[build-dependencies]
43-
anyhow = "1"
44-
git2 = "0.20"
43+
anyhow = { version = "1", optional = true }
44+
git2 = { version = "0.20", optional = true }
4545

4646
[features]
4747
default = []
4848
nolog = ["log/max_level_off"]
49+
reload-ssh-algo = ["dep:anyhow", "dep:git2"]
4950

5051
[[example]]
5152
name = "client"

build/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
#[cfg(feature = "reload-ssh-algo")]
12
mod define_parser;
3+
#[cfg(feature = "reload-ssh-algo")]
24
mod openssh;
5+
#[cfg(feature = "reload-ssh-algo")]
36
mod src_writer;
47

8+
#[cfg(feature = "reload-ssh-algo")]
59
fn main() -> anyhow::Result<()> {
6-
// If reload SSH ALGO is not set, we don't need to do anything
7-
if std::env::var("RELOAD_SSH_ALGO").is_err() {
8-
return Ok(());
9-
}
10-
1110
let prefs = openssh::get_my_prefs()?;
1211
src_writer::write_source(prefs)?;
1312

1413
Ok(())
1514
}
15+
16+
#[cfg(not(feature = "reload-ssh-algo"))]
17+
fn main() {}

0 commit comments

Comments
 (0)