-
-
Notifications
You must be signed in to change notification settings - Fork 6
Building from Source
Fabrício Bracht edited this page Jul 3, 2026
·
1 revision
Build and test the MQTT platform from source.
- Rust 1.88+ - Install via rustup
- cargo-make - Task runner
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install cargo-make
cargo install cargo-make- wasm-pack - For WASM builds
- Docker - For container builds
cargo install wasm-packgit clone https://github.com/LabOverWire/mqtt-lib.git
cd mqtt-lib# Build all crates
cargo build
# Build release version
cargo build --release
# Build specific crate
cargo build -p mqtt5
cargo build -p mqttv5-cli# Build
cargo make build
cargo make build-release
# Check compilation
cargo make checkRequired for TLS tests:
./scripts/generate_test_certs.sh# All tests
cargo test
# Fast unit tests only
cargo test --lib --bins
# Specific test
cargo test --test cli_functionality
# With output
cargo test -- --nocapture# Fast tests (unit + binary tests only)
cargo make test-fast
# All tests including integration
cargo make test
# QUIC integration tests
cargo make test-quic
# CLI functionality tests
cargo make test-cli# Run clippy (pedantic)
cargo clippy --all-targets --workspace -- -D warnings -W clippy::pedantic
# Using cargo-make
cargo make clippy
# Format code
cargo fmt
cargo make fmt
# Check formatting only
cargo make fmt-checkRun all checks that must pass before pushing:
cargo make ci-verifyThis runs, in order:
-
fmt-check-cargo fmt --all -- --check -
clippy- workspace clippy with-D warnings -
wasm-clippy- clippy for the WASM target -
build-cargo build -
test-fast- unit and binary tests -
test-cli- CLI functionality tests
For a lighter pre-commit check (formatting and linting only):
cargo make pre-commit# Check WASM compilation
cargo make wasm-verify
# Build WASM package
cargo make wasm-build# ARM Cortex-M4
cargo make embedded-cortex-m4
# RISC-V
cargo make embedded-riscv
# All embedded targets
cargo make embedded-verifycargo make all-targets# Simple broker
cargo run -p mqtt5 --example simple_broker
# Broker with TLS
cargo run -p mqtt5 --example broker_with_tls
# Broker with WebSocket
cargo run -p mqtt5 --example broker_with_websocket
# All transports
cargo run -p mqtt5 --example broker_all_transports
# With monitoring
cargo run -p mqtt5 --example broker_with_monitoring
# With OpenTelemetry
cargo run -p mqtt5 --example broker_with_opentelemetry --features opentelemetry# Simple client
cargo run -p mqtt5 --example simple_client
# Shared subscriptions
cargo run -p mqtt5 --example shared_subscription_demoEnable tracing for debugging:
# Basic debug
RUST_LOG=debug cargo test
# Specific crate
RUST_LOG=mqtt5=debug cargo test
# Transport layer
RUST_LOG=mqtt5::transport=trace cargo test
# All traces
RUST_LOG=trace cargo testPerformance is measured with the CLI bench subcommand rather than cargo bench:
# Build the CLI
cargo build --release -p mqttv5-cli
# Throughput benchmark
./target/release/mqttv5 bench --duration 15 --subscribers 5
# Latency benchmark (p50/p95/p99)
./target/release/mqttv5 bench --mode latency --duration 10
# Connection rate benchmark
./target/release/mqttv5 bench --mode connections --duration 10 --concurrency 10# Build Docker image
docker build -t mqtt5 .
# Build multi-arch
docker buildx build --platform linux/amd64,linux/arm64 -t mqtt5 .mqtt-lib/
├── crates/
│ ├── mqtt5/ # Native client + broker
│ ├── mqtt5-protocol/ # Protocol crate (no_std)
│ ├── mqtt5-wasm/ # WASM client + broker
│ └── mqttv5-cli/ # CLI tool
├── scripts/ # Helper scripts
├── test_certs/ # Generated test certificates
├── Makefile.toml # cargo-make tasks
└── Cargo.toml # Workspace manifest
Always use cargo commands (never edit Cargo.toml directly):
# Add dependency
cargo add serde -p mqtt5
# Add dev dependency
cargo add tokio-test --dev -p mqtt5
# Remove dependency
cargo remove some-crate -p mqtt5Error: No such file or directory: "test_certs/ca.pem"
Run:
./scripts/generate_test_certs.sherror: clippy warnings treated as errors
Fix all warnings or run:
cargo clippy --fix --allow-dirtyError: wasm32-unknown-unknown target not installed
Run:
rustup target add wasm32-unknown-unknownError: thumbv7em-none-eabihf target not installed
Run:
rustup target add thumbv7em-none-eabihfGetting Started
Broker Guide
Client Guide
Platform Guides
CLI Reference
Development