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 | |
| 17 | // Otherwise, only enable it if our feature is actually enabled. |
| 18 | if cfg!(feature = "proc-macro") { |
| 19 | println!("cargo:rustc-cfg=use_proc_macro"); |
| 20 | } |
| 21 | } |