CFG Aliases
CFG Aliases is a tiny utility to help save you a lot of effort with long winded #[cfg()]
checks. For example:
Cargo.toml:
[]
= "0.1.0-alpha.0"
build.rs:
use cfg_aliases;
Now that we have our aliases setup we can use them just like you would expect:
println!;
println!;
This greatly improves what would otherwise look like this without the aliases:
println!;
println!;
You can also use the cfg!
macro or combine your aliases with other checks using all()
, not()
, and any()
. Your aliases are genuine cfg
flags now!
if cfg! else
compile_error!;
Attribution and Thanks
- Thanks to my God and Father who led me through figuring this out and to whome I owe everything.
- Thanks to @Yandros on the Rust forum for showing me some crazy macro hacks!
- Thanks to @sfackler for pointing out the way to make cargo add the cfg flags.
- Thanks to the authors of the
tectonic_cfg_support::target_cfg
macro from which most of the cfg attribute parsing logic is taken from. Also thanks to @ratmice for bringing it up on the Rust forum.