Talk to Cargo easily at build time, brought to you by Nikolai Vazquez.

This library provides:

Convenience macros for communicating with Cargo during the build.rs phrase. Cargo listens to certain build script outputs that dictate how it should behave.

An accessible location for seeing what script build outputs are available to emit.

Protection against typos that can be made when printing these formatted outputs directly yourself. Mistyping macro names will result in a compile failure.

This crate is available on crates.io and can be used by adding the following to your project's Cargo.toml :

[build-dependencies] cargo-emit = "0.1"

and something like this to your build.rs :

if should_warn { cargo_emit :: warning ! ( "(C-3PO voice) We're doomed" ); }

Note: This library is meant to be used with Rust 2018 edition, so that cargo_emit:: can be used to prefix macro calls.

This crate is compatible with Rust 1.31+ in order to use the $crate::macro! feature introduced in Rust 2018.

Very thorough examples are provided in the docs for each individual macro.

This project is made freely available (as in free beer), but unfortunately not all beer is free! So, if you would like to buy me a beer (or coffee or more), then consider supporting my work that's benefited your project and thousands of others.