rust-most/build.rs

43 lines
1.0 KiB
Rust
Raw Normal View History

2019-12-04 10:17:05 -08:00
use cc::Build;
2019-12-06 02:01:59 -08:00
use std::path::{Path, PathBuf};
use std::fs::read_dir;
2019-12-04 10:17:05 -08:00
fn main() {
println!("Running build script");
2019-12-05 03:19:41 -08:00
let most_src = Path::new("vendor/most-5.1.0/src");
println!("Most src path: {}", most_src.display());
2019-12-04 10:17:05 -08:00
2019-12-06 01:56:17 -08:00
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() {
2019-12-06 02:01:59 -08:00
println!("Including C source file: {}", entry.display());
2019-12-06 01:56:17 -08:00
}
2019-12-04 10:17:05 -08:00
Build::new()
2019-12-06 01:56:17 -08:00
.files(c_files)
2019-12-04 10:17:05 -08:00
.include(most_src)
2019-12-06 01:56:17 -08:00
.include("/usr/bin/slang.h")
.flag("-lslang")
2019-12-04 10:17:05 -08:00
.compile("most");
2019-12-06 01:56:17 -08:00
2019-12-06 01:58:13 -08:00
println!("cargo:rustc-link-lib=dylib=slang");
2019-12-04 10:17:05 -08:00
}