-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
50 lines (44 loc) · 1.24 KB
/
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
44
45
46
47
48
49
50
fn main() -> Result<(), ()> {
let is_zh_cn = sys_locale::get_locale() == Some("zh-CN".into());
let mut num = 0;
for flag in [
"ACTIX_WEB",
"AXUM",
"NTEX",
"POEM",
"ROCKET",
"SALVO",
"VIZ",
] {
if std::env::var(format!("CARGO_FEATURE_{}", flag)).is_ok() {
num += 1;
}
}
if num != 1 {
let features =
"\"actix-web\", \"axum\", \"ntex\", \"poem\", \"rocket\", \"salvo\", \"viz\"";
if is_zh_cn {
eprintln!("以下feature中有且仅有一个可以被启用:{}。", features);
} else {
eprintln!(
"One and only one of the following features can be enabled: {}.",
features
);
}
if num == 0 {
if is_zh_cn {
eprintln!("您一个也没有启用它们。");
} else {
eprintln!("You haven't enabled any of them.");
}
} else {
if is_zh_cn {
eprintln!("您启用了它们中的多个。");
} else {
eprintln!("You have multiple of them enabled.");
}
}
return Err(());
}
Ok(())
}