diff --git a/src/cmd/sources.rs b/src/cmd/sources.rs index 45413aed..f32d13b3 100644 --- a/src/cmd/sources.rs +++ b/src/cmd/sources.rs @@ -11,6 +11,7 @@ use indexmap::{IndexMap, IndexSet}; use serde_json; use tokio::runtime::Runtime; +use crate::config::Validate; use crate::error::*; use crate::sess::{Session, SessionIo}; use crate::src::SourceGroup; @@ -148,6 +149,8 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> { }); } + srcs = srcs.validate("", false, &sess.suppress_warnings)?; + let mut target_defines: IndexMap> = IndexMap::new(); target_defines.extend( targets diff --git a/src/config.rs b/src/config.rs index e134e94b..cd474959 100644 --- a/src/config.rs +++ b/src/config.rs @@ -489,7 +489,28 @@ impl Validate for PartialManifest { export_include_dirs: exp_inc_dirs .iter() .filter_map(|path| match env_path_from_string(path.to_string()) { - Ok(parsed_path) => Some(Ok(parsed_path)), + Ok(parsed_path) => { + if (parsed_path.exists() && parsed_path.is_dir()) + || suppress_warnings.contains("E31") + || pre_output + { + if !(suppress_warnings.contains("W31") + || pre_output + || parsed_path.exists() && parsed_path.is_dir()) + { + warnln!( + "[W31] Include directory {} doesn't exist.", + &parsed_path.display() + ); + } + Some(Ok(parsed_path)) + } else { + Some(Err(Error::new(format!( + "[E31] Include directory {} doesn't exist", + &parsed_path.display() + )))) + } + } Err(cause) => { if suppress_warnings.contains("E30") { if !suppress_warnings.contains("W30") { diff --git a/src/sess.rs b/src/sess.rs index b88f1db6..fa6fb29e 100644 --- a/src/sess.rs +++ b/src/sess.rs @@ -30,8 +30,7 @@ use tokio::sync::Semaphore; use typed_arena::Arena; use crate::cli::read_manifest; -//use crate::config::Validate; -use crate::config::{self, Config, Manifest}; +use crate::config::{self, Config, Manifest, PartialManifest}; use crate::error::*; use crate::git::Git; use crate::src::SourceGroup; @@ -1160,15 +1159,22 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> { .join(format!("{}_manifest.yml", dep.name)) .exists() { - match read_manifest( - &self - .sess + let file = std::fs::File::open( + self.sess .root .join(".bender") .join("tmp") .join(format!("{}_manifest.yml", dep.name)), - &self.sess.suppress_warnings, - ) { + ) + .map_err(|cause| { + Error::chain(format!("Cannot open manifest {:?}.", path), cause) + })?; + let partial: PartialManifest = + serde_yaml_ng::from_reader(file).map_err(|cause| { + Error::chain(format!("Syntax error in manifest {:?}.", path), cause) + })?; + + match partial.validate_ignore_sources("", true, &self.sess.suppress_warnings) { Ok(m) => { if dep.name != m.package.name && !self.sess.suppress_warnings.contains("W11") @@ -1181,6 +1187,26 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> { Err(e) => Err(e), } } else { + if !(self.sess.suppress_warnings.contains("E32") + && self.sess.suppress_warnings.contains("W32")) + { + if let DepSrc::Path(ref path) = dep.source { + if !path.exists() { + if self.sess.suppress_warnings.contains("E32") { + warnln!( + "[W32] Path {:?} for dependency {:?} does not exist.", + path, + dep.name + ); + } else { + return Err(Error::new(format!( + "[E32] Path {:?} for dependency {:?} does not exist.", + path, dep.name + ))); + } + } + } + } if !self.sess.suppress_warnings.contains("W12") { warnln!( "[W12] Manifest not found for {:?} at {:?}", diff --git a/src/src.rs b/src/src.rs index 45f8ad21..ce5eeb05 100644 --- a/src/src.rs +++ b/src/src.rs @@ -58,6 +58,23 @@ impl<'ctx> Validate for SourceGroup<'ctx> { .into_iter() .map(|f| f.validate(package_name, pre_output, suppress_warnings)) .collect::, Error>>()?, + include_dirs: self + .include_dirs + .into_iter() + .map(|p| { + if (p.exists() && p.is_dir()) || suppress_warnings.contains("E31") { + if !(suppress_warnings.contains("W31") || p.exists() && p.is_dir()) { + warnln!("[W31] Include directory {} doesn't exist.", p.display()); + } + Ok(p) + } else { + Err(Error::new(format!( + "[E31] Include directory {} doesn't exist.", + p.display() + ))) + } + }) + .collect::, Error>>()?, ..self }) }