Interactive cargo subcommand to easily select, configure, and build workspace crates with remembered preferences.
Note: This tool is still under development with new features still underway.
Working in a multi-crate workspace often means typing repetitive, long commands:
cargo build -p <package> --features <feature1,feature2> --release
cargo smart-build remembers your choices.
Simply run cargo smart-build once, select your package and features interactively, and build. Next time? Just run it again—it remembers everything.
- Interactive Workspace Selection: Automatically detects workspace members and lets you select the package to build from a list.
- Execution Modes:
cargo smart-build(orbuild): Builds the selected crate.cargo smart-build run: Builds and runs the binary.cargo smart-build test: Runs tests for the selected crate/features.
- Target Selector:
- Auto-detects installed Rust targets via
rustup. - Allows selecting a specific target architecture (e.g.,
wasm32-unknown-unknown) or using the default native target. - Supports installing new targets directly from the UI.
- Seamless Cross-Compilation: Automatically switches to use
crosswhen a non-native target is selected (requires Docker). - Auto-Install: Prompts to install
crossif it's missing.
- Auto-detects installed Rust targets via
- Smart Defaults: Remembers your last selected package, build mode, target, and features. These are pre-selected (and highlighted in green) the next time you run the tool.
- Build Mode Toggle: Easily switch between Debug and Release builds without manual flags.
- Feature Management:
- Lists all available features for the selected package (excluding
default). - Allows multi-selection of features.
- Remembers enabled features for each package.
- Lists all available features for the selected package (excluding
- Persistence: Saves your preferences locally in a
.smart-build/config.jsonfile, so your environment is always ready.
Install via cargo:
cargo install cargo-smart-build-
Navigate to the root of your Cargo workspace.
-
Run one of the following commands:
# Build only cargo smart-build # Run binary cargo smart-build run # Run tests cargo smart-build test
-
Follow the interactive prompts:
- Select Package: Choose the crate you want to build/run/test.
- Select Build Mode: Choose
DebugorRelease. - Select Features: Toggle features on/off (Space to select, Enter to confirm).
-
The tool will execute the appropriate cargo command (
build,run,test).
Your preferences are stored in .smart-build/config.json in your workspace root. You can add .smart-build/ to your .gitignore if you don't want to commit personal build preferences.
This project is licensed under the MIT License.
