File: build.rs

package info (click to toggle)
rust-wasm-bindgen 0.2.104-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 308 kB
  • sloc: makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,385 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Required so that `[package] links = ...` works in `Cargo.toml`.

use rustversion_compat as rustversion;
use std::env;

macro_rules! deprecated_crate_feature {
    ($name:literal) => {
        #[cfg(feature = $name)]
        {
            println!("cargo:warning=The `{}` feature is deprecated and will be removed in the next major version.", $name);
        }
    };
}

fn main() {
    println!("cargo:rerun-if-changed=build.rs");

    deprecated_crate_feature!("msrv");
    deprecated_crate_feature!("rustversion");
    deprecated_crate_feature!("xxx_debug_only_print_generated_code");

    println!("cargo:rustc-check-cfg=cfg(wbg_diagnostic)");

    if rustversion::cfg!(since(1.78)) {
        println!("cargo:rustc-cfg=wbg_diagnostic");
    }

    let target_arch = env::var_os("CARGO_CFG_TARGET_ARCH").unwrap();
    let target_os = env::var_os("CARGO_CFG_TARGET_OS").unwrap();

    let target_features = env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or_default();
    let target_features: Vec<_> = target_features.split(',').map(str::trim).collect();

    println!("cargo:rustc-check-cfg=cfg(wbg_reference_types)");

    if target_features.contains(&"reference-types")
        || (target_arch == "wasm32"
            && target_os == "unknown"
            && rustversion::cfg!(all(since(1.82), before(1.84))))
    {
        println!("cargo:rustc-cfg=wbg_reference_types");
    }
}