From efcf7b87eee646f3249364b5ebf8ff114904af72 Mon Sep 17 00:00:00 2001 From: Avi Cohen Date: Mon, 6 Apr 2026 13:18:32 +0300 Subject: [PATCH] apollo_compilation_utils: remove dead install_compiler_binary and legacy paths Remove code that is no longer used after the switch to script-based compiler installation: - Remove install_compiler_binary() and legacy_binary_path() - Remove shared_folder_dir(), target_dir() from paths.rs - Remove tempfile build-dependency from apollo_compilation_utils - Update workflow artifact path and BUILD file Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/apollo_compilation_utils/Cargo.toml | 4 -- .../src/build_utils.rs | 65 ------------------- crates/apollo_compilation_utils/src/paths.rs | 17 ----- 3 files changed, 86 deletions(-) diff --git a/crates/apollo_compilation_utils/Cargo.toml b/crates/apollo_compilation_utils/Cargo.toml index de5b935f4ab..56d50cdfd0c 100644 --- a/crates/apollo_compilation_utils/Cargo.toml +++ b/crates/apollo_compilation_utils/Cargo.toml @@ -28,7 +28,3 @@ thiserror.workspace = true apollo_infra_utils.workspace = true assert_matches.workspace = true rstest.workspace = true - -[build-dependencies] -apollo_infra_utils.workspace = true -tempfile.workspace = true diff --git a/crates/apollo_compilation_utils/src/build_utils.rs b/crates/apollo_compilation_utils/src/build_utils.rs index cffb925a94a..1f6a66b64cb 100644 --- a/crates/apollo_compilation_utils/src/build_utils.rs +++ b/crates/apollo_compilation_utils/src/build_utils.rs @@ -1,71 +1,6 @@ use std::path::Path; use std::process::Command; -use tempfile::TempDir; - -use crate::paths::{legacy_binary_path, shared_folder_dir}; - -pub fn install_compiler_binary( - binary_name: &str, - required_version: &str, - cargo_install_args: &[&str], - out_dir: &std::path::Path, -) { - let binary_path = legacy_binary_path(out_dir, binary_name); - match Command::new(&binary_path).args(["--version"]).output() { - Ok(binary_version) => { - let binary_version = String::from_utf8(binary_version.stdout) - .expect("Failed to convert the binary version to a string."); - if binary_version.contains(required_version) { - println!("The {binary_name} binary is up to date."); - return; - } else { - println!( - "The {binary_name} binary is not up to date. Installing the required version." - ); - std::fs::remove_file(&binary_path).expect("Failed to remove the old binary."); - } - } - Err(_) => { - println!("The {binary_name} binary is not installed. Installing the required version."); - } - } - - let temp_cargo_path = TempDir::new().expect("Failed to create a temporary directory."); - let post_install_file_path = temp_cargo_path.path().join("bin").join(binary_name); - - let install_command_status = Command::new("cargo") - .args([ - "install", - "--root", - temp_cargo_path.path().to_str().expect("Failed to convert cargo_path to str"), - "--locked", - ]) - .args(cargo_install_args) - .status() - .unwrap_or_else(|_| panic!("Failed to install {binary_name}")); - - if !install_command_status.success() { - panic!("Failed to install {binary_name}"); - } - - // Move the '{binary_name}' executable to a shared location. - std::fs::create_dir_all(shared_folder_dir(out_dir)) - .expect("Failed to create shared executables folder"); - let move_command_status = Command::new("mv") - .args([post_install_file_path.as_os_str(), binary_path.as_os_str()]) - .status() - .expect("Failed to perform mv command."); - - if !move_command_status.success() { - panic!("Failed to move the {binary_name} binary to the shared folder."); - } - - std::fs::remove_dir_all(temp_cargo_path).expect("Failed to remove the cargo directory."); - - println!("Successfully set executable file: {:?}", binary_path.display()); -} - /// Verifies that a compiler binary is installed and has the required version. /// Panics with installation instructions if the binary is missing or has the wrong version. /// diff --git a/crates/apollo_compilation_utils/src/paths.rs b/crates/apollo_compilation_utils/src/paths.rs index 0880cf7a2d2..60220e3395e 100644 --- a/crates/apollo_compilation_utils/src/paths.rs +++ b/crates/apollo_compilation_utils/src/paths.rs @@ -4,18 +4,6 @@ use std::path::PathBuf; -fn target_dir(out_dir: &std::path::Path) -> std::path::PathBuf { - out_dir - .ancestors() - .nth(3) - .expect("Failed to navigate up three levels from OUT_DIR") - .to_path_buf() -} - -pub fn shared_folder_dir(out_dir: &std::path::Path) -> std::path::PathBuf { - target_dir(out_dir).join("shared_executables") -} - /// Returns `/-/bin/`, where /// `cargo_tools_root` resolves to `$CARGO_TOOLS_ROOT`, else `$CARGO_HOME/tools`, /// else `$HOME/.cargo/tools`. @@ -39,8 +27,3 @@ fn cargo_tools_root() -> PathBuf { }); cargo_home.join("tools") } - -// TODO(Avi): Remove once build.rs callers are gone. -pub fn legacy_binary_path(out_dir: &std::path::Path, binary_name: &str) -> std::path::PathBuf { - shared_folder_dir(out_dir).join(binary_name) -}