diff --git a/ethers-solc/src/artifacts/mod.rs b/ethers-solc/src/artifacts/mod.rs index 142b5a69..0487ba48 100644 --- a/ethers-solc/src/artifacts/mod.rs +++ b/ethers-solc/src/artifacts/mod.rs @@ -823,6 +823,12 @@ impl CompilerOutput { 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 diff --git a/ethers-solc/src/compile/mod.rs b/ethers-solc/src/compile/mod.rs index af34c54f..7f4d48db 100644 --- a/ethers-solc/src/compile/mod.rs +++ b/ethers-solc/src/compile/mod.rs @@ -410,7 +410,12 @@ impl Solc { /// Convenience function for compiling all sources under the given path pub fn compile_source(&self, path: impl AsRef) -> Result { 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