Skip to content

Commit 75e9f22

Browse files
authored
Merge pull request #78 from block65/fix/trim-vergen-deps
fix(build): strip unused vergen cargo/rustc features
2 parents 825f2f8 + a0ad162 commit 75e9f22

10 files changed

Lines changed: 99 additions & 82 deletions

File tree

.github/workflows/pr.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
if: runner.environment != 'self-hosted'
5454
with:
5555
shared-key: musl
56-
workspaces: . -> target/musl
5756

5857
- name: Install cross
5958
run: |
@@ -70,7 +69,7 @@ jobs:
7069
run: docker build -t wallhack-cross:x86_64-unknown-linux-musl -f Dockerfile.cross-musl .
7170

7271
- name: Test (musl — primary)
73-
run: CARGO_TARGET_DIR=target/musl cross test --release --target x86_64-unknown-linux-musl
72+
run: cross test --release --target x86_64-unknown-linux-musl
7473

7574
build-musl:
7675
needs: [test-musl]
@@ -85,7 +84,6 @@ jobs:
8584
if: runner.environment != 'self-hosted'
8685
with:
8786
shared-key: musl
88-
workspaces: . -> target/musl
8987

9088
- name: Install cross
9189
run: |
@@ -102,14 +100,14 @@ jobs:
102100
run: docker build -t wallhack-cross:x86_64-unknown-linux-musl -f Dockerfile.cross-musl .
103101

104102
- name: Build slim (musl — primary)
105-
run: CARGO_TARGET_DIR=target/musl cross build --release --target x86_64-unknown-linux-musl -p wallhack-cli --no-default-features --features slim
103+
run: cross build --release --target x86_64-unknown-linux-musl -p wallhack-cli --no-default-features --features slim
106104

107105
- name: Check slim binary size (musl — primary)
108106
run: ./bench/check_bloat.sh --no-build --only=slim-musl
109107
continue-on-error: true
110108

111109
- name: Build default (musl — primary)
112-
run: CARGO_TARGET_DIR=target/musl cross build --release --target x86_64-unknown-linux-musl -p wallhack-cli
110+
run: cross build --release --target x86_64-unknown-linux-musl -p wallhack-cli
113111

114112
- name: Check default binary size (musl — primary)
115113
run: ./bench/check_bloat.sh --no-build --only=default-musl

Cargo.lock

Lines changed: 2 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pedantic = "warn"
1111
[workspace.dependencies]
1212
arc-swap = "1"
1313
tokio = { version = "1.0" }
14-
tracing = "0.1"
14+
tracing = { version = "0.1", default-features = false, features = ["std", "release_max_level_debug"] }
1515
thiserror = "2"
1616
console-subscriber = "0.4"
1717
parking_lot = "0.12"

bench/check_bloat.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mkdir -p "$RESULTS_DIR"
2121
cd "$ROOT_DIR"
2222

2323
# --- Size thresholds (bytes) ---
24+
# DO NOT BUMP WITHOUT PERMISSION.
2425
# Updated: 2026-03-15, baseline: worktree-mcp-server
2526
# slim threshold = exactly 5MiB (5 * 1024 * 1024). Must stay "5MB slim".
2627
# default threshold = existing measured + ~1% headroom.

crates/cli/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ name = "wallhackctl"
1212
path = "src/bin/wallhack.rs"
1313

1414
[features]
15-
default = ["quic", "websocket", "http-api", "repl"]
15+
default = ["quic", "websocket", "http-api", "repl", "json"]
16+
json = ["dep:serde_json"]
1617
slim = ["quic", "websocket"]
1718

1819
# Transport features (forwarded to wallhackd)
@@ -30,7 +31,7 @@ repl = ["dep:reedline", "dep:nu-ansi-term"]
3031
argh = "0.1"
3132
prost = "0.13"
3233
serde = { version = "1", features = ["derive"] }
33-
serde_json = "1"
34+
serde_json = { version = "1", optional = true }
3435
wallhack-ipc = { path = "../ipc" }
3536
rand = { version = "0.9", default-features = false, features = ["std", "std_rng"] }
3637
# Already a transitive dep via reedline — no additional binary cost.
@@ -51,7 +52,8 @@ wallhackd = { path = "../daemon", default-features = false }
5152
zeroize = "1"
5253

5354
[build-dependencies]
54-
vergen-gitcl = { version = "9.1", features = ["build", "cargo", "rustc"] }
55+
anyhow = "1"
56+
vergen-gitcl = { version = "9.1", features = ["build"] }
5557

5658
[lints]
5759
workspace = true

crates/cli/build.rs

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,47 @@
1-
use vergen_gitcl::{BuildBuilder, CargoBuilder, Emitter, GitclBuilder, RustcBuilder};
1+
// NOTE: This WallhackBuildEnv impl is duplicated in crates/mcp/build.rs.
2+
// build.rs files cannot share code via library crates.
3+
use std::collections::BTreeMap;
24

3-
fn main() -> Result<(), Box<dyn std::error::Error>> {
4-
// PROFILE is a standard Cargo build env var; emit it for use via env!() in source.
5-
println!(
6-
"cargo:rustc-env=WALLHACK_BUILD_PROFILE={}",
7-
std::env::var("PROFILE").unwrap_or_else(|_| "unknown".to_string())
8-
);
5+
use vergen_gitcl::{
6+
AddCustomEntries, BuildBuilder, CargoRerunIfChanged, CargoWarning, DefaultConfig, Emitter,
7+
GitclBuilder,
8+
};
9+
10+
#[derive(Default)]
11+
struct WallhackBuildEnv;
12+
13+
impl AddCustomEntries<&str, &str> for WallhackBuildEnv {
14+
fn add_calculated_entries(
15+
&self,
16+
_idempotent: bool,
17+
cargo_rustc_env_map: &mut BTreeMap<&str, &str>,
18+
_cargo_rerun_if_changed: &mut CargoRerunIfChanged,
19+
_cargo_warning: &mut CargoWarning,
20+
) -> anyhow::Result<()> {
21+
let profile = std::env::var("PROFILE").unwrap_or_else(|_| "unknown".to_string());
22+
cargo_rustc_env_map.insert(
23+
"WALLHACK_BUILD_PROFILE",
24+
Box::leak(profile.into_boxed_str()),
25+
);
26+
Ok(())
27+
}
928

29+
fn add_default_entries(
30+
&self,
31+
_config: &DefaultConfig,
32+
_cargo_rustc_env_map: &mut BTreeMap<&str, &str>,
33+
_cargo_rerun_if_changed: &mut CargoRerunIfChanged,
34+
_cargo_warning: &mut CargoWarning,
35+
) -> anyhow::Result<()> {
36+
Ok(())
37+
}
38+
}
39+
40+
fn main() -> Result<(), Box<dyn std::error::Error>> {
1041
Emitter::default()
1142
.add_instructions(&BuildBuilder::default().build_timestamp(true).build()?)?
1243
.add_instructions(&GitclBuilder::default().sha(true).dirty(true).build()?)?
13-
.add_instructions(
14-
&CargoBuilder::default()
15-
.target_triple(true)
16-
.features(true)
17-
.build()?,
18-
)?
19-
.add_instructions(&RustcBuilder::default().semver(true).build()?)?
44+
.add_custom_instructions(&WallhackBuildEnv)?
2045
.emit()?;
2146
Ok(())
2247
}

crates/cli/src/bin/wallhack.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ async fn run_ctl_async(cli: wallhack_cli::cli::Cli) -> Result<(), output::CtlErr
309309
}),
310310
CtlCommand::Info(_) => management_request::Request::Status(StatusRequest {}),
311311
CtlCommand::Stats(_) => management_request::Request::Stats(StatsRequest {}),
312+
#[cfg(feature = "json")]
312313
CtlCommand::Peers(ref cmd) if cmd.json => {
313314
// JSON output: make the request and short-circuit the standard response path.
314315
let request = management_request::Request::Peers(PeersRequest {});

crates/cli/src/output.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
use std::io::Write;
44

55
use tabwriter::TabWriter;
6-
use wallhack_wire::management::{
7-
ManagementResponse, PeerInfo as WirePeerInfo, management_response,
8-
};
6+
use wallhack_wire::management::{ManagementResponse, management_response};
7+
8+
#[cfg(feature = "json")]
9+
use wallhack_wire::management::PeerInfo as WirePeerInfo;
910

1011
#[cfg(feature = "repl")]
1112
use {
@@ -15,6 +16,7 @@ use {
1516

1617
use crate::ipc::IpcError;
1718

19+
#[cfg(feature = "json")]
1820
#[derive(serde::Serialize)]
1921
struct PeerJson<'a> {
2022
name: &'a str,
@@ -50,6 +52,7 @@ fn format_uptime(ms: u64) -> String {
5052
/// Print the peers list as JSON to stdout.
5153
///
5254
/// Shape matches the REST API `/peers` response plus a `tun_name` field.
55+
#[cfg(feature = "json")]
5356
pub fn print_peers_json(peers: &[WirePeerInfo]) {
5457
let items: Vec<PeerJson<'_>> = peers
5558
.iter()

crates/mcp/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ wallhack-ipc = { path = "../ipc", features = ["vsock"] }
1616
wallhack-wire = { path = "../wire" }
1717

1818
[build-dependencies]
19-
vergen-gitcl = { version = "9.1", features = ["build", "cargo"] }
19+
anyhow = "1"
20+
vergen-gitcl = { version = "9.1", features = ["build"] }
2021

2122
[lints.rust]
2223
unsafe_code = "deny"

crates/mcp/build.rs

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,47 @@
1-
use vergen_gitcl::{BuildBuilder, CargoBuilder, Emitter, GitclBuilder};
1+
// NOTE: This WallhackBuildEnv impl is duplicated in crates/cli/build.rs.
2+
// build.rs files cannot share code via library crates.
3+
use std::collections::BTreeMap;
4+
5+
use vergen_gitcl::{
6+
AddCustomEntries, BuildBuilder, CargoRerunIfChanged, CargoWarning, DefaultConfig, Emitter,
7+
GitclBuilder,
8+
};
9+
10+
#[derive(Default)]
11+
struct WallhackBuildEnv;
12+
13+
impl AddCustomEntries<&str, &str> for WallhackBuildEnv {
14+
fn add_calculated_entries(
15+
&self,
16+
_idempotent: bool,
17+
cargo_rustc_env_map: &mut BTreeMap<&str, &str>,
18+
_cargo_rerun_if_changed: &mut CargoRerunIfChanged,
19+
_cargo_warning: &mut CargoWarning,
20+
) -> anyhow::Result<()> {
21+
let profile = std::env::var("PROFILE").unwrap_or_else(|_| "unknown".to_string());
22+
cargo_rustc_env_map.insert(
23+
"WALLHACK_BUILD_PROFILE",
24+
Box::leak(profile.into_boxed_str()),
25+
);
26+
Ok(())
27+
}
28+
29+
fn add_default_entries(
30+
&self,
31+
_config: &DefaultConfig,
32+
_cargo_rustc_env_map: &mut BTreeMap<&str, &str>,
33+
_cargo_rerun_if_changed: &mut CargoRerunIfChanged,
34+
_cargo_warning: &mut CargoWarning,
35+
) -> anyhow::Result<()> {
36+
Ok(())
37+
}
38+
}
239

340
fn main() -> Result<(), Box<dyn std::error::Error>> {
4-
println!(
5-
"cargo:rustc-env=WALLHACK_BUILD_PROFILE={}",
6-
std::env::var("PROFILE").unwrap_or_else(|_| "unknown".to_string())
7-
);
841
Emitter::default()
942
.add_instructions(&BuildBuilder::default().build_timestamp(true).build()?)?
1043
.add_instructions(&GitclBuilder::default().sha(true).dirty(true).build()?)?
11-
.add_instructions(&CargoBuilder::default().target_triple(true).build()?)?
44+
.add_custom_instructions(&WallhackBuildEnv)?
1245
.emit()?;
1346
Ok(())
1447
}

0 commit comments

Comments
 (0)