Skip to content

fix(build): isolate voip example so the demo build drops cpal/alsa-sys - #922

Merged
jlucaso1 merged 1 commit into
mainfrom
fix/demo-build-drop-cpal
Jun 28, 2026
Merged

fix(build): isolate voip example so the demo build drops cpal/alsa-sys#922
jlucaso1 merged 1 commit into
mainfrom
fix/demo-build-drop-cpal

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Problem

Production deploys (Coolify, which builds cargo build --example demo from the Dockerfile) started failing right after the VoIP PR, with:

error: failed to run custom build command for `alsa-sys v0.4.0`
The pkg-config command could not be found.

Root cause

Cargo compiles every root [dev-dependencies] when building any --example, even ones demo.rs never touches. The VoIP PR added cpal (and ringbuf) as a dev-dependency for examples/voip.rs only. So cargo build --example demo dragged in cpal -> alsa-sys, which needs pkg-config plus ALSA dev libraries, both absent in the Alpine/musl builder. cargo chef cook did not catch it because it only cooks the library dependency graph, not the examples.

Installing ALSA in the Dockerfile is not a real fix: the build is a static musl binary on scratch, so alsa-sys would still emit -lasound into the demo link (a binary that does not even use audio), breaking the static link or the runtime on scratch. The right move is for demo to not touch VoIP at all.

Fix

Move examples/voip.rs into its own workspace crate, examples/voip-cli/, which owns cpal/ringbuf, and drop both from the root dev-dependencies. It is a workspace member but not in default-members, so a plain cargo build skips it; run the example with cargo run -p whatsapp-rust-voip-cli.

Result: cargo tree -p whatsapp-rust -i alsa-sys finds nothing anymore, and the demo build no longer compiles the audio stack.

Dependency cleanup (cargo shear)

While here, two genuinely unused dependencies (confirmed manually) are removed:

The remaining cargo shear reports were reviewed and are false positives or intentional, so they are left as-is: serde in waproto (derive injected by build.rs), getrandom (the wasm_js backend), dhat/libsqlite3-sys (feature enablers), and the bench-integration "misplaced" ones (pre-existing, out of scope).

Local validation

  • cargo build --example demo compiles without touching cpal/alsa-sys.
  • cargo build -p whatsapp-rust-voip-cli compiles.
  • cargo build -p e2e-tests --tests compiles without prost.

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).
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The inline voip example is removed from the root workspace and replaced with a new standalone whatsapp-rust-voip-cli crate under examples/voip-cli/. Related root dev-dependencies (cpal, ringbuf) and a workspace dependency (postcard) are removed. An unused prost dependency is dropped from the e2e test crate.

VoIP CLI Migration

Layer / File(s) Summary
New voip-cli standalone crate
examples/voip-cli/Cargo.toml, Cargo.toml
Introduces the whatsapp-rust-voip-cli crate manifest with package metadata, workspace and local path dependencies (wacore, whatsapp-rust with voip features), and registers it as a workspace member.
Root workspace cleanup
Cargo.toml, tests/e2e/Cargo.toml
Removes the [[example]] voip target, cpal and ringbuf dev-dependencies, the postcard workspace dependency, and the prost dep from e2e tests.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: isolating the VoIP example to keep audio deps out of demo builds.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description directly matches the changes, explaining the VoIP example split, dependency cleanup, and build-failure fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/demo-build-drop-cpal

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

📦 Binary size report

Metric main PR Δ
bin size (stripped) 10.10 MiB 10.10 MiB 0
bin .text 8.16 MiB 8.16 MiB 0
bin allocated (text+data+bss) 10.10 MiB 10.10 MiB 0
llvm-lines wacore 644,533 644,533 0
llvm-lines wacore copies 17,879 17,879 0
llvm-lines whatsapp-rust lib 658,431 658,431 0
llvm-lines whatsapp-rust lib copies 20,447 20,447 0
deps crates (Cargo.lock) 465 466 +1 (+0.22%) 🔺
.text per crate
Crate main PR Δ
.text whatsapp_rust 1.49 MiB 1.49 MiB 0
.text wacore 527.65 KiB 527.65 KiB 0
.text wacore_binary 155.84 KiB 155.84 KiB 0
.text wacore_libsignal 165.86 KiB 165.86 KiB 0
.text wacore_appstate 144.24 KiB 144.24 KiB 0
.text wacore_noise 27.71 KiB 27.71 KiB 0
.text waproto 871.99 KiB 871.99 KiB 0
.text whatsapp_rust_sqlite_storage 475.07 KiB 475.07 KiB 0
.text whatsapp_rust_tokio_transport 43.67 KiB 43.67 KiB 0
.text whatsapp_rust_ureq_http_client 8.81 KiB 8.81 KiB 0
.text std 995.60 KiB 995.60 KiB 0
.text other deps 3.29 MiB 3.29 MiB 0
Top movers (cargo-bloat attribution)
Crate main PR Δ
regex_automata 2.90 KiB 1.63 KiB -1.26 KiB (-43.61%)
prost 370.63 KiB 371.90 KiB +1.26 KiB (+0.34%)

Baseline: 301f2e030 (latest main run) · Head: cf554bcc7 · Graphs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Re-trigger cubic

@codspeed-hq

codspeed-hq Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 179 untouched benchmarks


Comparing fix/demo-build-drop-cpal (55d94a8) with main (301f2e0)

Open in CodSpeed

@jlucaso1
jlucaso1 merged commit 9c6ee8a into main Jun 28, 2026
16 checks passed
@jlucaso1
jlucaso1 deleted the fix/demo-build-drop-cpal branch June 28, 2026 04:59
jlucaso1 added a commit to oxidezap/whatsapp-rust-docs that referenced this pull request Jun 28, 2026
…split

The VoIP example was moved from examples/voip.rs to its own workspace
crate at examples/voip-cli/src/main.rs (whatsapp-rust PR #922). Update
all references and add the new run command.

References: oxidezap/whatsapp-rust#922
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant