blob: d37ce99f8f83b8d5236255f92ff7c1a00b76761a [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") {
14 return
15 }
16
Alex Crichtonf3d1b2c2018-08-11 21:56:16 -070017 // 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 Crichton53548482018-08-11 21:54:05 -070023 // 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}