feat(solc): install solc io reporter in basic reporter (#1295)

This commit is contained in:
Matthias Seitz 2022-05-23 00:20:54 +02:00 committed by GitHub
parent 75835a9280
commit 0656ffcec3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 3 deletions

View File

@ -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);