interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / zmij / build.rs

45 lines · 1362 bytes Raw Blame History
1use std::env;
2use std::ffi::OsString;
3use std::process::{self, Command};
4use std::str;
5
6fn main() {
7 println!("cargo:rerun-if-changed=build.rs");
8
9 let rustc = rustc_minor_version().unwrap_or(u32::MAX);
10
11 if rustc >= 80 {
12 println!("cargo:rustc-check-cfg=cfg(exhaustive)");
13 println!("cargo:rustc-check-cfg=cfg(opt_level, values(\"s\"))");
14 println!("cargo:rustc-check-cfg=cfg(zmij_no_select_unpredictable)");
15 }
16
17 if rustc < 88 {
18 // https://doc.rust-lang.org/std/hint/fn.select_unpredictable.html
19 println!("cargo:rustc-cfg=zmij_no_select_unpredictable");
20 }
21
22 if let Some(opt_level) = env::var_os("OPT_LEVEL") {
23 if opt_level == "s" || opt_level == "z" {
24 println!("cargo:rustc-cfg=opt_level=\"s\"");
25 }
26 }
27}
28
29fn rustc_minor_version() -> Option<u32> {
30 let rustc = cargo_env_var("RUSTC");
31 let output = Command::new(rustc).arg("--version").output().ok()?;
32 let version = str::from_utf8(&output.stdout).ok()?;
33 let mut pieces = version.split('.');
34 if pieces.next() != Some("rustc 1") {
35 return None;
36 }
37 pieces.next()?.parse().ok()
38}
39
40fn cargo_env_var(key: &str) -> OsString {
41 env::var_os(key).unwrap_or_else(|| {
42 eprintln!("Environment variable ${key} is not set during execution of build script");
43 process::exit(1);
44 })
45}