-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.rs
52 lines (44 loc) · 1.44 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
extern crate bindgen;
// use cmake;
use std::env;
use std::path::PathBuf;
fn main() {
// std::fs::copy(
// "CMakeLists-ta-lib-0.6.0-rc.1.replace.txt",
// "3rdparty/ta-lib/CMakeLists.txt",
// )
// .unwrap();
// std::fs::copy(
// "cmake_install.ta-lib-0.6.0-rc.1.replace.cmake",
// "3rdparty/ta-lib/cmake_install.cmake",
// )
// .unwrap();
let dst = cmake::Config::new("./3rdparty/ta-lib")
.define("TA_LIB_VERSION_FULL", "0.6.0.rc.1")
.build();
println!(
"cargo:rustc-link-search=native={}",
dst.join("lib").display()
);
// Tell rustc to use nng static library
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
if target_os == "windows" {
println!("cargo:rustc-link-lib=static=ta_lib_a");
} else {
println!("cargo:rustc-link-lib=static=ta_lib");
}
// println!("cargo:rustc-link-lib=static=ta_lib");
// let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
// println!(
// "cargo:rustc-link-search=native={}",
// Path::new(&dir).join("./3rdparty/ta-lib/lib/").display()
// );
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}