| name | build-rust |
| description | Build Rust code with proper error handling, optimization, and workspace support for development, testing, and production |
Rust Build Operations
Build Rust workspaces efficiently with the build-rust CLI.
CLI Usage
./scripts/build-rust.sh dev
./scripts/build-rust.sh release
./scripts/build-rust.sh profile
./scripts/build-rust.sh check
./scripts/build-rust.sh clean
./scripts/build-rust.sh release do-memory-core
Build Modes
| Mode | Use Case | Flags |
|---|
dev | Development iteration | --workspace |
release | Production deployment | --release --workspace |
profile | Performance analysis | --release --timings |
check | Fast validation | --workspace (type-check only) |
Disk Space Optimization (ADR-032)
Dev profile reduces target/ size (~5.2 GB to ~2 GB):
[profile.dev]
debug = "line-tables-only"
[profile.dev.package."*"]
debug = false
[profile.dev.build-override]
opt-level = 3
Cleanup: ./scripts/clean-artifacts.sh quick|standard|full
Offload: CARGO_TARGET_DIR=/mnt/fastssd/rslm-target ./scripts/build-rust.sh dev
Error Handling
| Issue | Fix |
|---|
| Timeout | CARGO_BUILD_JOBS=4 cargo build or use check |
| Memory | cargo build -j 1 or monitor with /usr/bin/time -v |
| Dep conflicts | cargo update then `cargo tree -d |
| Cross-compilation | rustup target add x86_64-unknown-linux-musl |
Common Workflows
./scripts/code-quality.sh fmt && ./scripts/code-quality.sh clippy --workspace
cargo build --release --workspace && cargo nextest run --all && cargo test --doc
cargo check -p do-memory-core && cargo test -p do-memory-core --lib
cargo build --release --workspace && strip target/release/do-memory-mcp
Troubleshooting
| Issue | Fix |
|---|
| Incremental cache corruption | cargo clean && cargo build |
| Stale lock file | rm Cargo.lock && cargo generate-lockfile |
| Rust version mismatch | rustup update stable && rustup default stable |
Verification Checklist
References
ADR-032 (Disk Space), ADR-036 (Dependency Deduplication)