forked from anderslanglands/oiio-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
64 lines (53 loc) · 2.41 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
56
57
58
59
60
61
62
63
64
use cmake;
use std::path::Path;
pub fn main() {
let oiio_root = std::env::var("OIIO_ROOT")
.expect("OIIO_ROOT must be set to root of OIIO installation");
let openexr_root = std::env::var("OPENEXR_ROOT")
.expect("OPENEXR_ROOT must be set to root of OPENEXR installation");
let oiio_lib_suffix = std::env::var("OIIO_LIB_SUFFIX").unwrap_or("".into());
let openexr_lib_suffix =
std::env::var("OPENEXR_LIB_SUFFIX").unwrap_or("".into());
let lib_name = format!("libOpenImageIO{}.so", oiio_lib_suffix);
let inc_oiio = Path::new(&oiio_root).join("include");
let inc_openexr = Path::new(&openexr_root).join("include");
let lib_oiio = Path::new(&oiio_root).join("lib").join(lib_name);
let ilmimf_lib_name = format!("IlmImf{}.so", openexr_lib_suffix);
let ilmimf_lib_path = Path::new(&openexr_root)
.join("lib")
.join(format!("lib{}", &ilmimf_lib_name));
let iex_lib_name = format!("Iex{}.so", openexr_lib_suffix);
let iex_lib_path = Path::new(&openexr_root)
.join("lib")
.join(format!("lib{}", &iex_lib_name));
let dst_coiio = cmake::Config::new("coiio")
.define("INC_OIIO", &inc_oiio)
.define("LIB_OIIO", &lib_oiio)
.define("LIB_ILMIMF", &ilmimf_lib_path)
.define("LIB_IEX", &iex_lib_path)
.define("INC_OPENEXR", &inc_openexr)
.always_configure(false)
.build();
let openexr_lib_path = Path::new(&openexr_root).join("lib");
println!("cargo:rustc-link-search=native={}", dst_coiio.display());
println!(
"cargo:rustc-link-search=native={}",
openexr_lib_path.display()
);
println!(
"cargo:rustc-link-search=native={}",
Path::new(&oiio_root).join("lib").display()
);
// panic!(
// "openexr_lib_path: {}\nilmilmf_lib_name: {}\niex_lib_name: {}\nilmimf_lib_path: {}\n, iex_lib_path: {}",
// openexr_lib_path.display(), ilmimf_lib_name, iex_lib_name, ilmimf_lib_path.display(), iex_lib_path.display()
// );
println!("cargo:rustc-link-lib=static=coiio");
println!("cargo:rustc-link-lib=dylib=OpenImageIO{}", oiio_lib_suffix);
// println!("cargo:rustc-link-lib=dylib={}", ilmimf_lib_name);
// println!("cargo:rustc-link-lib=dylib={}", iex_lib_name);
#[cfg(target_os = "linux")]
println!("cargo:rustc-link-lib=dylib=stdc++");
#[cfg(target_os = "macos")]
println!("cargo:rustc-link-lib=dylib=c++");
}