Skip to content

Commit 8f5f979

Browse files
avi-starkwareclaude
andcommitted
apollo_compilation_utils: add verify_compiler_binary
New function that checks a compiler binary's version at runtime and panics with installation instructions if missing or wrong version. Added alongside the existing install_compiler_binary — no callers yet. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 041ed51 commit 8f5f979

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

crates/apollo_compilation_utils/src/build_utils.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::path::Path;
12
use std::process::Command;
23

34
use tempfile::TempDir;
@@ -64,3 +65,27 @@ pub fn install_compiler_binary(
6465

6566
println!("Successfully set executable file: {:?}", binary_path.display());
6667
}
68+
69+
/// Verifies that a compiler binary is installed and has the required version.
70+
/// Panics with installation instructions if the binary is missing or has the wrong version.
71+
pub fn verify_compiler_binary(binary_path: &Path, required_version: &str) {
72+
let binary_name = binary_path.display();
73+
match Command::new(binary_path).arg("--version").output() {
74+
Ok(output) => {
75+
let version_str = String::from_utf8_lossy(&output.stdout);
76+
if !version_str.contains(required_version) {
77+
panic!(
78+
"{binary_name} version {required_version} is required, but found: \
79+
{version_str}. Run 'scripts/install_compiler_binaries.sh' to install the \
80+
correct version."
81+
);
82+
}
83+
}
84+
Err(_) => {
85+
panic!(
86+
"{binary_name} not found. Run 'scripts/install_compiler_binaries.sh' to install \
87+
it."
88+
);
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)