fixed logic error + no incs case

This commit is contained in:
Noah Swerhun 2023-12-13 10:41:35 -06:00
parent 63f12eac4d
commit 4ce746e845

View file

@ -153,7 +153,7 @@ impl Makefile {
panic!("error: makefile contains one mgen guard but not the other. cannot continue.");
}
if ! contains_start && contains_end {
if !(contains_start && contains_end) {
let include_dirs = Makefile::get_include_dirs(&contents);
return Makefile { path: String::from(path), prologue: contents,
mgen_zone: String::from(""), epilogue: String::from(""), include_dirs };
@ -176,11 +176,14 @@ impl Makefile {
}
fn get_include_dirs(search: &String) -> Vec<String> {
let mut include_dirs: Vec<String> = Vec::new();
let makefile_regex = Regex::new(r"^INCS\s*=\s*(.*?)$").unwrap();
let caps = makefile_regex.captures_iter(search);
let (_, [dirlist]) = caps.map(|c| c.extract()).last().unwrap();
let mut include_dirs: Vec<String> = Vec::new();
let dirlist = match caps.map(|c| c.extract()).last() {
Some((_, [v])) => v,
None => return include_dirs,
};
let incdir_regex = Regex::new(r"-s*-I\s*(.*?)\s*").unwrap();
let caps = incdir_regex.captures_iter(&dirlist);