blob: aaa92b6f6e7da5599fc7f5d626875af2fbd02dee [file] [log] [blame]
Alex Crichton53548482018-08-11 21:54:05 -07001use std::env;
2
3fn 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
11fn 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") {
David Tolnay5a556cf2018-08-12 13:49:39 -070014 return;
Alex Crichton53548482018-08-11 21:54:05 -070015 }
16
Alex Crichton53548482018-08-11 21:54:05 -070017 // 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}