From 55d94a8620198209373361cf21c7bfcda42dd2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lucas?= Date: Sun, 28 Jun 2026 01:46:16 -0300 Subject: [PATCH] fix(build): isolate voip example so the demo build drops cpal/alsa-sys Cargo compiles every root dev-dependency when building any --example, so `cargo build --example demo` (the binary the Docker image ships) pulled cpal, and with it alsa-sys, which needs pkg-config plus ALSA dev libraries. Those are absent in the Alpine/musl builder, so production deploys started failing on alsa-sys right after the voip PR added cpal as a dev-dependency. Move examples/voip.rs into a standalone workspace member (examples/voip-cli) that owns cpal and ringbuf, and drop both from the root dev-dependencies. The demo build no longer touches the audio stack; run the voip example with `cargo run -p whatsapp-rust-voip-cli`. Also drop two genuinely unused dependencies surfaced by cargo shear: the `postcard` workspace dependency (referenced by no member) and `prost` in the e2e test crate (unused in its code). --- Cargo.lock | 21 +++++++++++-- Cargo.toml | 14 +-------- examples/voip-cli/Cargo.toml | 34 ++++++++++++++++++++++ examples/{voip.rs => voip-cli/src/main.rs} | 0 tests/e2e/Cargo.toml | 1 - 5 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 examples/voip-cli/Cargo.toml rename examples/{voip.rs => voip-cli/src/main.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index 7cd91aeb7..28ae73334 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1163,7 +1163,6 @@ dependencies = [ "futures", "hex", "log", - "prost", "tokio", "uuid", "wacore", @@ -4243,7 +4242,6 @@ dependencies = [ "bytes", "cbc 0.2.1", "chrono", - "cpal", "env_logger", "event-listener", "flate2", @@ -4259,7 +4257,6 @@ dependencies = [ "portable-atomic", "prost", "rand 0.10.1", - "ringbuf", "rustls", "scopeguard", "serde", @@ -4331,6 +4328,24 @@ dependencies = [ "wacore", ] +[[package]] +name = "whatsapp-rust-voip-cli" +version = "0.6.0" +dependencies = [ + "anyhow", + "async-channel", + "cpal", + "env_logger", + "hex", + "log", + "portable-atomic", + "rand 0.10.1", + "ringbuf", + "tokio", + "wacore", + "whatsapp-rust", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index c5a3a5a09..c225dd217 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ description = "Rust client for WhatsApp Web" [workspace] members = [ ".", + "examples/voip-cli", "http_clients/ureq-client", "storages/sqlite-storage", "tests/bench-integration", @@ -76,7 +77,6 @@ itoa = "1" log = "0.4" metrics = "0.24" portable-atomic = { version = "1", default-features = false, features = ["fallback"] } -postcard = { version = "1", default-features = false, features = ["use-std"] } prost = { version = "0.14.4", default-features = false, features = ["std"] } prost-build = { version = "0.14.4", default-features = false } prost-types = { version = "0.14.4", default-features = false, features = ["std"] } @@ -202,19 +202,11 @@ getrandom = { workspace = true, features = ["wasm_js"] } aes = { workspace = true } async-trait = { workspace = true } cbc = { workspace = true, features = ["block-padding"] } -# Cross-platform audio I/O for the `voip` example only. A dev-dependency, so it -# never reaches consumers of the published lib (and only compiles when an example -# that uses it is built). Needs libasound2-dev (ALSA) on Linux. -cpal = "0.18" env_logger = { workspace = true } flate2 = { workspace = true } hkdf = { workspace = true } hmac = { workspace = true } metrics-exporter-prometheus = "0.18" -# Lock-free SPSC ring to hand samples from the async drain task to cpal's -# realtime output callback without locking or per-callback allocation. voip -# example only (dev-dependency). -ringbuf = "0.5" sha2 = { workspace = true } tokio = { workspace = true, features = ["full"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } @@ -244,10 +236,6 @@ required-features = ["tracing"] name = "metrics" required-features = ["metrics"] -[[example]] -name = "voip" -required-features = ["voip", "sqlite-storage", "tokio-transport", "ureq-client", "tokio-native"] - [profile.release] opt-level = 3 debug = false diff --git a/examples/voip-cli/Cargo.toml b/examples/voip-cli/Cargo.toml new file mode 100644 index 000000000..2dacbef9b --- /dev/null +++ b/examples/voip-cli/Cargo.toml @@ -0,0 +1,34 @@ +# Standalone crate for the VoIP audio demo. Lives outside the root package so its +# audio stack (cpal -> alsa-sys, needs ALSA/pkg-config on Linux) never enters the +# dependency closure of `cargo build --example demo`, which the Docker image runs. +# A workspace member but not a default-member: plain `cargo build` skips it; build +# it explicitly with `cargo run -p whatsapp-rust-voip-cli`. +[package] +name = "whatsapp-rust-voip-cli" +version = "0.6.0" +edition = "2024" +license = "MIT" +publish = false + +[dependencies] +anyhow = { workspace = true } +async-channel = { workspace = true } +cpal = "0.18" +env_logger = { workspace = true } +hex = { workspace = true } +log = { workspace = true } +portable-atomic = { workspace = true } +rand = { workspace = true } +ringbuf = "0.5" +tokio = { workspace = true, features = ["full"] } +wacore = { path = "../../wacore", features = ["voip"] } +whatsapp-rust = { path = "../..", features = [ + "voip", + "sqlite-storage", + "tokio-transport", + "ureq-client", + "tokio-native", +] } + +[lints] +workspace = true diff --git a/examples/voip.rs b/examples/voip-cli/src/main.rs similarity index 100% rename from examples/voip.rs rename to examples/voip-cli/src/main.rs diff --git a/tests/e2e/Cargo.toml b/tests/e2e/Cargo.toml index bcefe6391..4e044dd4d 100644 --- a/tests/e2e/Cargo.toml +++ b/tests/e2e/Cargo.toml @@ -39,7 +39,6 @@ whatsapp-rust-ureq-http-client = { path = "../../http_clients/ureq-client", feat env_logger = { workspace = true } hex = { workspace = true } log = { workspace = true } -prost = { workspace = true } [lints] workspace = true