Maraiah/tycho/build.rs

61 lines
1.6 KiB
Rust
Raw Normal View History

2019-06-09 13:02:26 -07:00
use rust_qt_binding_generator::*;
use std::{io::prelude::*, path::PathBuf};
2019-06-09 13:02:26 -07:00
fn main()
{
let (lty, dty, qtpre, cxx) = if cfg!(target_os = "macos") {
("framework", "framework", "Qt", "c++")
} else {
("dylib", "native", "Qt5", "stdc++")
};
2019-06-09 13:02:26 -07:00
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
let mut config = configuration::parse("bindings.json").unwrap();
config.overwrite_implementation = true;
config.cpp_file = out_dir.join("bindings.cc");
config.rust.dir = out_dir;
generate_bindings(&config).unwrap();
2019-06-13 18:10:33 -07:00
let mut config = cmake::Config::new(".");
2019-06-09 13:02:26 -07:00
2019-06-13 18:10:33 -07:00
if cfg!(debug_assertions) {
2019-07-02 14:57:10 -07:00
config.cxxflag("-DTYCHO_DEBUG_ASSERTIONS");
2019-06-13 18:10:33 -07:00
}
2019-07-03 22:51:27 -07:00
let out_dir = config.build();
let lib_dir = out_dir.join("lib");
let etc_dir = out_dir.join("etc");
2019-07-03 22:51:27 -07:00
println!("cargo:rustc-link-search=native={}", lib_dir.display());
println!("cargo:rustc-link-lib=static=maraiah-tycho-hermes");
let fp = std::fs::File::open(etc_dir.join("link.txt")).unwrap();
let fp = std::io::BufReader::new(fp);
for ln in fp.lines() {
let ln = ln.unwrap();
let path = PathBuf::from(&ln);
let path = path.parent().unwrap();
let path = if cfg!(target_os = "macos") {
path.parent().unwrap()
} else {
path
};
println!("cargo:rustc-link-search={}={}", dty, path.display());
}
println!("cargo:rustc-link-lib={}={}Core", lty, qtpre);
println!("cargo:rustc-link-lib={}={}Widgets", lty, qtpre);
println!("cargo:rustc-link-lib={}={}Gui", lty, qtpre);
println!("cargo:rustc-link-lib=dylib={}", cxx);
2019-06-09 13:02:26 -07:00
}
// EOF