-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
44 lines (37 loc) · 1.43 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
use std::env;
use std::fs;
use std::path::Path;
#[cfg(target_os = "linux")]
use std::process::Command;
#[cfg(target_os = "windows")]
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let dest_lib_path = Path::new(&out_dir).join("../../../deps").join(
"imgtype.lib",
);
let dest_dll_path = Path::new(&out_dir).join("../../..").join("imgtype.dll");
let _ = fs::copy("./vendor/imgtype.dll", dest_dll_path);
let _ = fs::copy("./vendor/imgtype.lib", dest_lib_path);
}
#[cfg(target_os = "macos")]
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let dest_lib_path = Path::new(&out_dir).join("lib").join("libimgtype.a");
let _ = fs::create_dir(Path::new(&out_dir).join("lib"));
let _ = fs::copy("./vendor/libimgtype.a.macos", dest_lib_path);
println!("cargo:rustc-link-search=native={}/lib", out_dir);
}
#[cfg(target_os = "linux")]
fn main() {
// git clone https://github.com/kjunichi/libimgtype.git
Command::new("git").args(&["clone","https://github.com/kjunichi/libimgtype.git"])
.status().unwrap();
// cd libimgtype
// go build -buildmode=c-archive -o libimgtype.a main.go
let out_dir = env::var("OUT_DIR").unwrap();
Command::new("go").args(&["build","-buildmode=c-archive","-o"])
.arg(&format!("{}/lib/libimgtype.a", out_dir))
.current_dir(Path::new("libimgtype"))
.status().unwrap();
println!("cargo:rustc-link-search=native={}/lib", out_dir);
}