use std::path::PathBuf;
fn main() {
let test_lib = std::process::Command::new("ld")
.args(&["-l", "itex2mml"])
.output()
.expect("failed to run yacc");
let stderr = test_lib.stderr;
if !(0..stderr.len()).any(|i| (&stderr[i..]).starts_with(b"itex2mml")) {
return;
}
let out_dir = std::env::var_os("OUT_DIR").map(PathBuf::from).unwrap();
let yacc_c = out_dir.join("y.tab.c");
let flex_c = out_dir.join("lex.yy.c");
std::process::Command::new("yacc")
.args(&[
"-p",
"itex2MML_yy",
"-d",
"src/itex2MML.y",
"-o",
&yacc_c.to_str().unwrap(),
])
.output()
.expect("failed to run yacc");
std::process::Command::new("flex")
.args(&[
"-Pitex2MML_yy",
&("-o".to_string() + flex_c.to_str().unwrap()),
"src/itex2MML.l",
])
.output()
.expect("failed to run flex");
cc::Build::new()
.include("src")
.files(&[flex_c.to_str().unwrap(), yacc_c.to_str().unwrap()])
.opt_level(3)
.static_flag(true)
.warnings(false)
.compile("itex2mml");
}