Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions crates/compilers/src/compilers/solc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ impl Compiler for SolcCompiler {

fn available_versions(&self, _language: &Self::Language) -> Vec<CompilerVersion> {
match self {
Self::Specific(solc) => vec![CompilerVersion::Installed(Version::new(
solc.version.major,
solc.version.minor,
solc.version.patch,
))],
Self::Specific(solc) => {
let mut v =
Version::new(solc.version.major, solc.version.minor, solc.version.patch);
v.build = solc.version.build.clone();
vec![CompilerVersion::Installed(v)]
}

#[cfg(feature = "svm-solc")]
Self::AutoDetect => {
Expand Down Expand Up @@ -158,7 +159,7 @@ impl CompilerInput for SolcVersionedInput {
}

fn compiler_name(&self) -> Cow<'static, str> {
"Solc".into()
"ssolc".into()
}

fn strip_prefix(&mut self, base: &Path) {
Expand Down
30 changes: 24 additions & 6 deletions crates/compilers/src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,19 +323,18 @@ impl Reporter for BasicStdoutReporter {
/// [`Compiler::compile()`]: crate::compilers::Compiler::compile
fn on_compiler_spawn(&self, compiler_name: &str, version: &Version, dirty_files: &[PathBuf]) {
println!(
"Compiling {} files with {} {}.{}.{}",
"Compiling {} files with {} {}",
dirty_files.len(),
compiler_name,
version.major,
version.minor,
version.patch
format_version_with_commit(version),
);
}

fn on_compiler_success(&self, compiler_name: &str, version: &Version, duration: &Duration) {
println!(
"{} {}.{}.{} finished in {duration:.2?}",
compiler_name, version.major, version.minor, version.patch
"{} {} finished in {duration:.2?}",
compiler_name,
format_version_with_commit(version),
);
}

Expand Down Expand Up @@ -375,6 +374,25 @@ pub fn format_unresolved_imports(imports: &[(&Path, &Path)], remappings: &[Remap
)
}

/// Extract short commit hash from version build metadata.
/// Handles format like "commit.676bdecc.Darwin.appleclang" → "676bdec"
pub fn extract_short_commit(version: &Version) -> Option<&str> {
let build = version.build.as_str();
let hash = build.strip_prefix("commit.")?;
let end = hash.find('.').unwrap_or(hash.len()).min(7);
Some(&hash[..end])
}

/// Format version with optional short commit hash for display.
/// Returns e.g. "0.8.31 (676bdec)" or "0.8.31" if no commit metadata.
pub fn format_version_with_commit(version: &Version) -> String {
if let Some(hash) = extract_short_commit(version) {
format!("{}.{}.{} ({hash})", version.major, version.minor, version.patch)
} else {
format!("{}.{}.{}", version.major, version.minor, version.patch)
}
}

/// Returned if setting the global reporter fails.
#[derive(Debug)]
pub struct SetGlobalReporterError {
Expand Down