You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

61 lines
1.4 KiB

fn llvm_config(args: Vec<&str>) -> String {
std::process::Command::new("llvm-config")
.args(args)
.output()
.map(|out| String::from_utf8(out.stdout).unwrap())
.unwrap()
.trim()
.to_owned()
}
fn split_to_array(string: String) -> Vec<String> {
string
.split(' ')
.filter(|lib| !lib.is_empty())
.map(|lib| lib.to_owned())
.collect()
}
fn with_components(mut v: Vec<&str>) -> Vec<&str> {
v.push("orcerror");
v.push("orcjit");
v.push("native");
v
}
fn main() {
let a_incdr = vec!["--includedir"];
let a_libdr = vec!["--libdir"];
let a_llibs = with_components(vec!["--libs", "--link-static"]);
let a_slibs = with_components(vec!["--system-libs", "--link-static"]);
let incdr = llvm_config(a_incdr);
let libdr = llvm_config(a_libdr);
let llibs = split_to_array(llvm_config(a_llibs));
let slibs = split_to_array(llvm_config(a_slibs));
println!("cargo:rustc-link-search=native={}", libdr);
for lib in llibs.into_iter().chain(slibs.into_iter()) {
println!("cargo:rustc-flags={}", lib);
}
#[cfg(any(
target_os = "macos",
target_os = "freebsd",
target_os = "openbsd"
))]
println!("cargo:rustc-link-lib=c++");
#[cfg(target_os = "linux")]
println!("cargo:rustc-link-lib=stdc++");
cc::Build::new()
.cpp(true)
.warnings_into_errors(true)
.static_flag(true)
.include(incdr)
.file("fw/vire/llvm.cxx")
.compile("helper");
}
// EOF