diff options
author | Melody Horn <melody@boringcactus.com> | 2021-04-06 14:22:19 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-04-06 14:22:19 -0600 |
commit | 455b77bdbc78729c4175e27a949327c9836b8794 (patch) | |
tree | 4f19ff3d9195cad8989e6b12a75394ca86065b38 /src/makefile/mod.rs | |
parent | 5a101a96ada9ddbd4be54c46cd7d0125825c2283 (diff) | |
download | makers-455b77bdbc78729c4175e27a949327c9836b8794.tar.gz makers-455b77bdbc78729c4175e27a949327c9836b8794.zip |
if an included makefile didn't exist, try building it
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 { |