rust-most/build.rs
2019-12-06 02:01:59 -08:00

43 lines
1.0 KiB
Rust

use cc::Build;
use std::path::{Path, PathBuf};
use std::fs::read_dir;
fn main() {
println!("Running build script");
let most_src = Path::new("vendor/most-5.1.0/src");
println!("Most src path: {}", most_src.display());
let c_files: Vec<PathBuf> = read_dir(most_src).unwrap()
.into_iter()
.filter(|entry| {
let path = entry.as_ref().unwrap().path();
match path.file_name() {
Some(s) if s.to_string_lossy() == "chkslang.c" => return false,
//Some(s) if s.to_string_lossy() == "main.c" => return false,
_ => ()
};
match path.extension() {
Some(ref s) if s.to_string_lossy() == "c" => true,
_ => false
}
})
.map(|entry| {
entry.unwrap().path()
}).collect();
for entry in c_files.iter() {
println!("Including C source file: {}", entry.display());
}
Build::new()
.files(c_files)
.include(most_src)
.include("/usr/bin/slang.h")
.flag("-lslang")
.compile("most");
println!("cargo:rustc-link-lib=dylib=slang");
}