#[macro_export]
macro_rules! rustc_flags {
(to: $stream:expr, $($flags:expr),+ $(,)?) => {
$($crate::pair!(to: $stream, "rustc-flags", "{}", $flags);)+
};
($($flags:expr),+ $(,)?) => {
$crate::rustc_flags!(to: std::io::stdout(), $($flags),+);
};
}
#[cfg(test)]
mod tests {
#[test]
fn single() {
insta::assert_display_snapshot!(
crate::capture_output(|output| {
crate::rustc_flags!(
to: output,
"FLAG"
);
}),
@"cargo:rustc-flags=FLAG\n"
);
}
#[test]
fn multiple() {
insta::assert_display_snapshot!(
crate::capture_output(|output| {
crate::rustc_flags!(
to: output,
"FLAG1",
"FLAG2",
);
}),
@"cargo:rustc-flags=FLAG1\n\
cargo:rustc-flags=FLAG2\n"
);
}
}