Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
feat(solc): install solc io reporter in basic reporter (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored May 22, 2022
1 parent 75835a9 commit 0656ffc
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions ethers-solc/src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,18 +330,27 @@ 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
fn on_solc_spawn(
&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(),
Expand All @@ -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);
Expand Down

0 comments on commit 0656ffc

Please sign in to comment.