This commit is contained in:
AlexK 2022-03-07 20:35:27 +04:00
parent 9368924300
commit a70729779c
2 changed files with 12 additions and 1 deletions

View File

@ -823,6 +823,12 @@ impl CompilerOutput {
err.source_location.as_ref().map(|s| files.contains(s.file.as_str())).unwrap_or(true) err.source_location.as_ref().map(|s| files.contains(s.file.as_str())).unwrap_or(true)
}); });
} }
pub fn merge(&mut self, other: CompilerOutput) {
self.errors.extend(other.errors);
self.contracts.extend(other.contracts);
self.sources.extend(other.sources);
}
} }
/// A wrapper helper type for the `Contracts` type alias /// A wrapper helper type for the `Contracts` type alias

View File

@ -410,7 +410,12 @@ impl Solc {
/// Convenience function for compiling all sources under the given path /// Convenience function for compiling all sources under the given path
pub fn compile_source(&self, path: impl AsRef<Path>) -> Result<CompilerOutput> { pub fn compile_source(&self, path: impl AsRef<Path>) -> Result<CompilerOutput> {
let path = path.as_ref(); let path = path.as_ref();
self.compile(&CompilerInput::new(path)?) let mut res: CompilerOutput = Default::default();
for input in CompilerInput::new(path)? {
let output = self.compile(&input)?;
res.merge(output)
}
Ok(res)
} }
/// Same as [`Self::compile()`], but only returns those files which are included in the /// Same as [`Self::compile()`], but only returns those files which are included in the