diff options
-rw-r--r-- | src/makefile/input.rs | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs index 912b119..e5473a1 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -2,7 +2,7 @@ use std::cell::Cell; use std::collections::HashMap; use std::error::Error as StdError; use std::fs::File; -use std::io::{BufRead, BufReader, Cursor, Error as IoError, Lines}; +use std::io::{BufRead, BufReader, Cursor, Error as IoError, ErrorKind as IoErrorKind, Lines}; use std::iter::Peekable; use std::path::Path; @@ -254,19 +254,28 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { let child_macros = self.macros.with_overlay(); let child = MakefileReader::read_file(self.args, child_macros, field) .with_context(|| format!("while including {}", field)); - if let Ok(child) = child { - let child = child.finish(); - self.extend(child); - } else { - if !original_line.starts_with('-') { - // TODO handle non-file-not-found errors - log::error!( - "{}:{}: included makefile {} not found", - &self.file_name, - line_number, - field - ); - self.failed_includes.push(field.to_owned()); + match child { + Ok(child) => { + let child = child.finish(); + self.extend(child); + } + Err(err) => { + if !original_line.starts_with('-') { + match err.downcast_ref::<IoError>() { + Some(err) if err.kind() == IoErrorKind::NotFound => { + log::error!( + "{}:{}: included makefile {} not found", + &self.file_name, + line_number, + field, + ); + self.failed_includes.push(field.to_owned()); + } + _ => { + return Err(err); + } + } + } } } } |