-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
50 lines (40 loc) · 1.36 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
use std::{collections::HashMap, path::Path, process::Command};
const FEATURES: &[(&str, &str)] = &[
("socketpair", "socketpair"),
("pipe2", "pipe2"),
("_fcntl_r", "fcntl"),
];
fn main() {
if std::env::var("DOCS_RS").is_ok() {
return;
}
println!("cargo:rerun-if-env-changed=VITASDK");
let vitasdk = std::env::var("VITASDK").expect("VITASDK not set");
let vitasdk = Path::new(&vitasdk);
let libc_a = vitasdk.join("arm-vita-eabi").join("lib").join("libc.a");
let nm = vitasdk.join("bin").join("arm-vita-eabi-nm");
println!("cargo:rerun-if-changed={}", libc_a.display());
println!("cargo:rerun-if-changed={}", nm.display());
let nm_result = Command::new(nm)
.arg("-n")
.arg(libc_a)
.output()
.expect("nm failed")
.stdout;
let nm_result = String::from_utf8_lossy(&nm_result);
let nm_result = nm_result.lines();
let mut features = FEATURES
.iter()
.map(|f| (*f, false))
.collect::<HashMap<_, _>>();
for line in nm_result {
for ((symbol, _), enabled) in &mut features {
if line == format!("00000000 T {}", symbol) {
*enabled = true;
}
}
}
for ((_, feature), _) in features.iter().filter(|(_, enabled)| !**enabled) {
println!("cargo:rustc-cfg=feature=\"{}\"", feature);
}
}