add macro util to determine if cargo build or check/clippy.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-09-25 05:04:25 +00:00 committed by strawberry
parent 43b0bb6a5e
commit c40d20cb95

View file

@ -2,6 +2,16 @@ use syn::{parse_str, Expr, Generics, Lit, Meta};
use crate::Result;
pub(crate) fn is_cargo_build() -> bool {
std::env::args()
.find(|flag| flag.starts_with("--emit"))
.as_ref()
.and_then(|flag| flag.split_once('='))
.map(|val| val.1.split(','))
.and_then(|mut vals| vals.find(|elem| *elem == "link"))
.is_some()
}
pub(crate) fn get_named_generics(args: &[Meta], name: &str) -> Result<Generics> {
const DEFAULT: &str = "<>";