cargo-wizard 0.2.0

Cargo subcommand for applying Cargo profile templates.
Documentation

cargo-wizard Build Status Latest Version

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

Demo of cargo-wizard

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

$ cargo install cargo-wizard

Usage

  • Interactive mode (CLI dialog that guides you through the process):
    $ cargo wizard
    
  • Non-interactive mode (directly apply a predefined template to your Cargo workspace):
    $ cargo wizard apply <template> <profile>
    # For example, apply `fast-runtime` template to the `dist` profile
    $ cargo wizard apply fast-runtime dist
    

You can enable profile/config options that require a nightly compiler by running cargo-wizard with a nightly Cargo (e.g. cargo +nightly wizard) or by using the --nightly flag.

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
  • 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.

You can also modify these templates in the interactive mode to build your own custom template.

Note that config.toml changes are applied to the global build.hostflags option, 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.

License

MIT