macro_rules! pair {
(to: $stream:expr, $key:expr, $value:expr $(, $($args:tt)*)?) => { ... };
($key:expr, $value:expr $(, $($args:tt)*)?) => { ... };
}
Expand description
Emits a $key
/$value
pair to Cargo based on build script outputs.
This is equivalent to:
println!("cargo:$key=$value");
This is the base macro upon which the other macros are built.
ยงExamples
This can be used to emit arbitrary user-defined metadata.
cargo_emit::pair!("root", "/path/to/root");
or, in case you want it to emit to a custom stream:
let mut stdout = std::io::stdout();
cargo_emit::pair!(
to: stdout,
"root", "/path/to/root"
);
The $key
and $value
parameters get concatenated into a single formatting
string. Formatting runtime values can be done by passing subsequent values.
let name = "foo";
cargo_emit::pair!("{lib}dir", "/path/to/{lib}", lib = name);