cargo-wizard

Cargo subcommand that applies predefined Cargo profile and config templates to your Cargo workspace to get you up to speed quickly.

Motivation
I often see Rust users asking online about how can they best configure Cargo get e.g. the fastest compilation times, best runtime performance or minimal binary size. While this information can be found in various books, repositories or blog posts, it is annoying to hunt for it everytime we want to configure a new Cargo project.
This tool tries to automate that process to make it easier.
Installation
Usage
- Interactive mode (CLI dialog that guides you through the process):
- Non-interactive mode (directly apply a predefined template to your Cargo workspace):
# For example, apply `fast-runtime` template to the `dist` profile
You can enable profile/config options that require a nightly compiler by running
cargo-wizardwith a nightly Cargo (e.g.cargo +nightly wizard) or by using the--nightlyflag.
Features
cargo-wizard can create or modify Cargo profiles in your Cargo.toml manifest and RUSTFLAGS in
the .cargo/config.toml file) based on a
set of prepared templates:
fast-compile- minimizes compilation times- Disables debuginfo generation and uses a faster linker.
- In nightly mode, it also enables the Cranelift codegen backend and the parallel frontend.
fast-runtime- maximizes runtime performance- Enables LTO and maximal optimization settings.
min-size- minimizes binary size- Similar to
fast-runtime, but uses optimization flags designed for small binary size.
- Similar to
You can also modify these templates in the interactive mode to build your own custom template.
Note that
config.tomlchanges are applied to the globalbuild.hostflagsoption, because per-profile Rustflags are still unstable.
Inspiration
Contributing
Contributions are welcome :)
Possible future features:
- Allow configuring the memory allocator.
- Load/store templates on disk to make them easier to share
Acknowledgements
cargo wizard uses the incredible toml_edit crate to keep original
formatting of the modified TOML files.