-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.rs
43 lines (34 loc) · 938 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;
extern crate pkg_config;
use pkg_config::{Config, Error};
fn is_static() -> bool {
env::var("CARGO_FEATURE_STATIC").is_ok()
}
fn cairo() -> Result<(), Error> {
if let Ok(path) = env::var("GTK_LIB_DIR") {
for lib in &["cairo"] {
println!("cargo:rustc-link-lib={}={}", if is_static() { "static" } else { "dynlib" }, lib);
}
println!("cargo:rustc-link-search=native={}", path);
}
else {
try!(Config::new().statik(is_static()).probe("cairo"));
}
Ok(())
}
fn pango() -> Result<(), Error> {
if let Ok(path) = env::var("GTK_LIB_DIR") {
for lib in &["pangocairo-1.0", "pango-1.0", "gobject-2.0", "glib-2.0"] {
println!("cargo:rustc-link-lib={}={}", if is_static() { "static" } else { "dynlib" }, lib);
}
println!("cargo:rustc-link-search=native={}", path);
}
else {
try!(Config::new().statik(is_static()).probe("pangocairo"));
}
Ok(())
}
fn main() {
cairo().unwrap();
pango().unwrap();
}