xref: /aosp_15_r20/prebuilts/rust/linux-musl-x86/1.80.1/src/stdlibs/library/std/build.rs (revision b40554a23088fb75aa6945dfe8e65169c8484da3)
1 use std::env;
2 
main()3 fn main() {
4     println!("cargo:rerun-if-changed=build.rs");
5     let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH was not set");
6     let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");
7     let target_vendor =
8         env::var("CARGO_CFG_TARGET_VENDOR").expect("CARGO_CFG_TARGET_VENDOR was not set");
9     let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV was not set");
10 
11     println!("cargo:rustc-check-cfg=cfg(netbsd10)");
12     if target_os == "netbsd" && env::var("RUSTC_STD_NETBSD10").is_ok() {
13         println!("cargo:rustc-cfg=netbsd10");
14     }
15 
16     println!("cargo:rustc-check-cfg=cfg(restricted_std)");
17     if target_os == "linux"
18         || target_os == "android"
19         || target_os == "netbsd"
20         || target_os == "dragonfly"
21         || target_os == "openbsd"
22         || target_os == "freebsd"
23         || target_os == "solaris"
24         || target_os == "illumos"
25         || target_os == "macos"
26         || target_os == "ios"
27         || target_os == "tvos"
28         || target_os == "watchos"
29         || target_os == "visionos"
30         || target_os == "windows"
31         || target_os == "fuchsia"
32         || (target_vendor == "fortanix" && target_env == "sgx")
33         || target_os == "hermit"
34         || target_os == ("trusty")
35         || target_os == "l4re"
36         || target_os == "redox"
37         || target_os == "haiku"
38         || target_os == "vxworks"
39         || target_arch == "wasm32"
40         || target_arch == "wasm64"
41         || target_os == "espidf"
42         || target_os.starts_with("solid")
43         || (target_vendor == "nintendo" && target_env == "newlib")
44         || target_os == "vita"
45         || target_os == "aix"
46         || target_os == "nto"
47         || target_os == "xous"
48         || target_os == "hurd"
49         || target_os == "uefi"
50         || target_os == "teeos"
51         || target_os == "zkvm"
52 
53         // See src/bootstrap/src/core/build_steps/synthetic_targets.rs
54         || env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()
55     {
56         // These platforms don't have any special requirements.
57     } else {
58         // This is for Cargo's build-std support, to mark std as unstable for
59         // typically no_std platforms.
60         // This covers:
61         // - os=none ("bare metal" targets)
62         // - mipsel-sony-psp
63         // - nvptx64-nvidia-cuda
64         // - arch=avr
65         // - JSON targets
66         // - Any new targets that have not been explicitly added above.
67         println!("cargo:rustc-cfg=restricted_std");
68     }
69 
70     println!("cargo:rustc-check-cfg=cfg(backtrace_in_libstd)");
71     println!("cargo:rustc-cfg=backtrace_in_libstd");
72 
73     println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap());
74 }
75