From 0656ffcec3fb93f6948515dd9bcb3814b1afb900 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 23 May 2022 00:20:54 +0200 Subject: [PATCH] feat(solc): install solc io reporter in basic reporter (#1295) --- ethers-solc/src/report/mod.rs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/ethers-solc/src/report/mod.rs b/ethers-solc/src/report/mod.rs index e87a586c..4d33285f 100644 --- a/ethers-solc/src/report/mod.rs +++ b/ethers-solc/src/report/mod.rs @@ -330,8 +330,16 @@ pub struct NoReporter(()); impl Reporter for NoReporter {} /// A [`Reporter`] that emits some general information to `stdout` -#[derive(Copy, Clone, Debug, Default)] -pub struct BasicStdoutReporter(()); +#[derive(Clone, Debug)] +pub struct BasicStdoutReporter { + solc_io_report: SolcCompilerIoReporter, +} + +impl Default for BasicStdoutReporter { + fn default() -> Self { + Self { solc_io_report: SolcCompilerIoReporter::from_default_env() } + } +} impl Reporter for BasicStdoutReporter { /// Callback invoked right before [`Solc::compile()`] is called @@ -339,9 +347,10 @@ impl Reporter for BasicStdoutReporter { &self, _solc: &Solc, version: &Version, - _input: &CompilerInput, + input: &CompilerInput, dirty_files: &[PathBuf], ) { + self.solc_io_report.log_compiler_input(input, version); println!( "Compiling {} files with {}.{}.{}", dirty_files.len(), @@ -351,6 +360,20 @@ impl Reporter for BasicStdoutReporter { ); } + fn on_solc_success( + &self, + _solc: &Solc, + version: &Version, + output: &CompilerOutput, + duration: &Duration, + ) { + self.solc_io_report.log_compiler_output(output, version); + println!( + "Solc {}.{}.{} finished in {:.2?}", + version.major, version.minor, version.patch, duration + ); + } + /// Invoked before a new [`Solc`] bin is installed fn on_solc_installation_start(&self, version: &Version) { println!("installing solc version \"{}\"", version);