use std::path::PathBuf;
fn main() {
let sfst_src_dir = PathBuf::from("src/sfst/src");
cc::Build::new()
.cpp(true)
.file("src/sfst_wrapper.cpp")
.include(&sfst_src_dir) .flag("-std=c++11")
.compile("sfst_wrapper");
let mut build = cc::Build::new();
build.cpp(true).include(&sfst_src_dir).flag("-std=c++11");
let source_files = [
"fst.cpp",
"alphabet.cpp",
"basic.cpp",
"compact.cpp",
"determinise.cpp",
"hopcroft.cpp",
"interface.cpp",
"operators.cpp",
"utf8.cpp",
];
for file in &source_files {
let file_path = sfst_src_dir.join(file);
if file_path.exists() {
build.file(file_path);
println!("cargo:rerun-if-changed=src/{}", file);
} else {
println!("cargo:warning=Missing source file: {}", file);
}
}
build.compile("sfst");
println!("cargo:rustc-link-lib=static=sfst_wrapper");
println!("cargo:rustc-link-lib=static=sfst");
println!("cargo:rustc-link-lib=stdc++");
println!("cargo:rerun-if-changed=src/sfst_wrapper.cpp");
println!("cargo:rerun-if-changed=src/sfst_wrapper.h");
}