blob: 37d90c70a589aae6c114b70aee2b09ccea83493e (
plain) (
blame)
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
|
extern crate gcc;
extern crate pkg_config;
fn libvt100() {
let dir = std::env::current_dir()
.unwrap_or_else(|e| { panic!("couldn't get cwd: {}", e) });;
std::env::set_current_dir("libvt100")
.unwrap_or_else(|e| { panic!("failed to chdir: {}", e) });
let absdir = std::env::current_dir()
.unwrap_or_else(|e| { panic!("couldn't get cwd: {}", e) });;
let out = std::process::Command::new("make")
.arg("static")
.output()
.unwrap_or_else(|e| { panic!("failed to exec: {}", e) });
std::env::set_current_dir(dir)
.unwrap_or_else(|e| { panic!("failed to chdir: {}", e) });
if !out.status.success() {
println!("{}", std::string::String::from_utf8_lossy(&out.stderr));
std::process::exit(out.status.code().unwrap_or(255));
}
println!("cargo:rustc-link-search=native={}", absdir.to_str().unwrap());
println!("cargo:rustc-link-lib=static=vt100");
}
fn glib() {
let lib_def = pkg_config::probe_library("glib-2.0")
.unwrap_or_else(|e| {
panic!("Couldn't find required dependency glib-2.0: {}", e);
});
for dir in lib_def.link_paths {
println!("cargo:rustc-link-search=native={}", dir.to_str().unwrap());
}
for lib in lib_def.libs {
println!("cargo:rustc-link-lib={}", lib);
}
}
fn libvt100_wrappers() {
gcc::compile_library("libvt100wrappers.a", &["src/ffi.c"]);
}
fn main() {
libvt100();
glib();
libvt100_wrappers();
}
|