forked from time-rs/time
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
43 lines (37 loc) · 935 Bytes
/
build.rs
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
use std::env;
fn cargo_web() {
if env::var("COMPILING_UNDER_CARGO_WEB") == Ok("1".into()) {
println!("cargo:rustc-cfg=cargo_web")
}
}
fn features(features: &[(&str, &str)]) {
for feature in features {
if env::var(format!("CARGO_FEATURE_{}", feature.0)).is_ok() {
println!("cargo:rustc-cfg={}", feature.1);
}
}
}
fn no_std() {
if env::var("CARGO_FEATURE_STD").is_err() {
println!("cargo:rustc-cfg=no_std");
}
}
#[rustversion::since(1.40.0)]
fn non_exhaustive() {
println!("cargo:rustc-cfg=supports_non_exhaustive");
}
#[rustversion::before(1.40.0)]
fn non_exhaustive() {}
fn main() {
cargo_web();
features(&[
("STD", "std"),
("DEPRECATED", "v01_deprecated_api"),
("PANICKING_API", "panicking_api"),
("RAND", "rand"),
("SERDE", "serde"),
("__DOC", "docs"),
]);
no_std();
non_exhaustive();
}