forked from kornelski/pngquant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
55 lines (45 loc) · 1.46 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
51
52
53
54
55
extern crate cc;
extern crate dunce;
use std::env;
use std::path::Path;
fn main() {
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set");
let mut cc = cc::Build::new();
cc.warnings(false);
cc.define("PNGQUANT_NO_MAIN", Some("1"));
if cfg!(feature = "openmp") {
cc.flag(&env::var("DEP_OPENMP_FLAG").unwrap());
}
if cfg!(feature = "cocoa") {
if cfg!(feature = "lcms2") {
println!("cargo:warning=Don't use both lcms2 and cocoa features at the same time, see --no-default-features");
}
cc.define("USE_COCOA", Some("1"));
}
else if cfg!(feature = "lcms2") {
if let Ok(p) = env::var("DEP_LCMS2_INCLUDE") {
cc.include(dunce::simplified(Path::new(&p)));
}
cc.define("USE_LCMS", Some("1"));
}
if env::var("PROFILE").map(|p|p != "debug").unwrap_or(true) {
cc.define("NDEBUG", Some("1"));
}
if target_arch == "x86_64" ||
(target_arch == "x86" && cfg!(feature = "sse")) {
cc.define("USE_SSE", Some("1"));
}
cc.file("rwpng.c");
cc.file("pngquant.c");
if let Ok(p) = env::var("DEP_IMAGEQUANT_INCLUDE") {
cc.include(dunce::simplified(Path::new(&p)));
} else {
cc.include("lib");
}
if let Ok(p) = env::var("DEP_PNG_INCLUDE") {
for p in env::split_paths(&p) {
cc.include(dunce::simplified(&p));
}
}
cc.compile("libpngquant.a");
}