Alex Crichton | 5354848 | 2018-08-11 21:54:05 -0700 | [diff] [blame] | 1 | use std::env; |
| 2 | |
| 3 | fn main() { |
| 4 | println!("cargo:rerun-if-changed=build.rs"); |
| 5 | |
| 6 | let target = env::var("TARGET").unwrap(); |
| 7 | |
| 8 | maybe_enable_use_proc_macro(&target); |
| 9 | } |
| 10 | |
| 11 | fn maybe_enable_use_proc_macro(target: &str) { |
| 12 | // wasm targets don't have the `proc_macro` crate, disable this feature. |
| 13 | if target.contains("wasm32") { |
| 14 | return |
| 15 | } |
| 16 | |
Alex Crichton | f3d1b2c | 2018-08-11 21:56:16 -0700 | [diff] [blame] | 17 | // There are currently no musl builds of the compiler, so proc_macro is |
| 18 | // always missing, so disable this feature. |
| 19 | if target.contains("-musl") { |
| 20 | return |
| 21 | } |
| 22 | |
Alex Crichton | 5354848 | 2018-08-11 21:54:05 -0700 | [diff] [blame] | 23 | // Otherwise, only enable it if our feature is actually enabled. |
| 24 | if cfg!(feature = "proc-macro") { |
| 25 | println!("cargo:rustc-cfg=use_proc_macro"); |
| 26 | } |
| 27 | } |