diff options
Diffstat (limited to 'src/makefile/mod.rs')
-rw-r--r-- | src/makefile/mod.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index aab5054..f17ba64 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -5,7 +5,7 @@ use std::fmt; use std::path::{Path, PathBuf}; use std::rc::Rc; -use eyre::{bail, eyre, Result}; +use eyre::{bail, eyre, Result, WrapErr}; use crate::args::Args; @@ -108,7 +108,7 @@ impl<'a> Makefile<'a> { } } - pub fn extend(&mut self, new: FinishedMakefileReader) { + pub fn extend(&mut self, new: FinishedMakefileReader) -> Result<()> { self.inference_rules.extend(new.inference_rules); self.macros.extend(new.macros); self.targets.borrow_mut().extend( @@ -119,6 +119,16 @@ impl<'a> Makefile<'a> { if self.first_non_special_target.is_none() { self.first_non_special_target = new.first_non_special_target; } + for failed_include in new.failed_includes { + // try rebuilding + self.update_target(&failed_include).wrap_err_with(|| { + format!("while building missing included file {}", &failed_include) + })?; + let macros = self.macros.with_overlay(); + let file = MakefileReader::read_file(self.args, macros, failed_include)?.finish(); + self.extend(file)?; + } + Ok(()) } fn special_target_has_prereq(&self, target: &str, name: &str) -> bool { |