Skip to content

Commit efcf7b8

Browse files
avi-starkwareclaude
andcommitted
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) <noreply@anthropic.com>
1 parent 3f0deb2 commit efcf7b8

3 files changed

Lines changed: 0 additions & 86 deletions

File tree

crates/apollo_compilation_utils/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,3 @@ thiserror.workspace = true
2828
apollo_infra_utils.workspace = true
2929
assert_matches.workspace = true
3030
rstest.workspace = true
31-
32-
[build-dependencies]
33-
apollo_infra_utils.workspace = true
34-
tempfile.workspace = true

crates/apollo_compilation_utils/src/build_utils.rs

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,6 @@
11
use std::path::Path;
22
use std::process::Command;
33

4-
use tempfile::TempDir;
5-
6-
use crate::paths::{legacy_binary_path, shared_folder_dir};
7-
8-
pub fn install_compiler_binary(
9-
binary_name: &str,
10-
required_version: &str,
11-
cargo_install_args: &[&str],
12-
out_dir: &std::path::Path,
13-
) {
14-
let binary_path = legacy_binary_path(out_dir, binary_name);
15-
match Command::new(&binary_path).args(["--version"]).output() {
16-
Ok(binary_version) => {
17-
let binary_version = String::from_utf8(binary_version.stdout)
18-
.expect("Failed to convert the binary version to a string.");
19-
if binary_version.contains(required_version) {
20-
println!("The {binary_name} binary is up to date.");
21-
return;
22-
} else {
23-
println!(
24-
"The {binary_name} binary is not up to date. Installing the required version."
25-
);
26-
std::fs::remove_file(&binary_path).expect("Failed to remove the old binary.");
27-
}
28-
}
29-
Err(_) => {
30-
println!("The {binary_name} binary is not installed. Installing the required version.");
31-
}
32-
}
33-
34-
let temp_cargo_path = TempDir::new().expect("Failed to create a temporary directory.");
35-
let post_install_file_path = temp_cargo_path.path().join("bin").join(binary_name);
36-
37-
let install_command_status = Command::new("cargo")
38-
.args([
39-
"install",
40-
"--root",
41-
temp_cargo_path.path().to_str().expect("Failed to convert cargo_path to str"),
42-
"--locked",
43-
])
44-
.args(cargo_install_args)
45-
.status()
46-
.unwrap_or_else(|_| panic!("Failed to install {binary_name}"));
47-
48-
if !install_command_status.success() {
49-
panic!("Failed to install {binary_name}");
50-
}
51-
52-
// Move the '{binary_name}' executable to a shared location.
53-
std::fs::create_dir_all(shared_folder_dir(out_dir))
54-
.expect("Failed to create shared executables folder");
55-
let move_command_status = Command::new("mv")
56-
.args([post_install_file_path.as_os_str(), binary_path.as_os_str()])
57-
.status()
58-
.expect("Failed to perform mv command.");
59-
60-
if !move_command_status.success() {
61-
panic!("Failed to move the {binary_name} binary to the shared folder.");
62-
}
63-
64-
std::fs::remove_dir_all(temp_cargo_path).expect("Failed to remove the cargo directory.");
65-
66-
println!("Successfully set executable file: {:?}", binary_path.display());
67-
}
68-
694
/// Verifies that a compiler binary is installed and has the required version.
705
/// Panics with installation instructions if the binary is missing or has the wrong version.
716
///

crates/apollo_compilation_utils/src/paths.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@
44

55
use std::path::PathBuf;
66

7-
fn target_dir(out_dir: &std::path::Path) -> std::path::PathBuf {
8-
out_dir
9-
.ancestors()
10-
.nth(3)
11-
.expect("Failed to navigate up three levels from OUT_DIR")
12-
.to_path_buf()
13-
}
14-
15-
pub fn shared_folder_dir(out_dir: &std::path::Path) -> std::path::PathBuf {
16-
target_dir(out_dir).join("shared_executables")
17-
}
18-
197
/// Returns `<cargo_tools_root>/<binary>-<version>/bin/<binary>`, where
208
/// `cargo_tools_root` resolves to `$CARGO_TOOLS_ROOT`, else `$CARGO_HOME/tools`,
219
/// else `$HOME/.cargo/tools`.
@@ -39,8 +27,3 @@ fn cargo_tools_root() -> PathBuf {
3927
});
4028
cargo_home.join("tools")
4129
}
42-
43-
// TODO(Avi): Remove once build.rs callers are gone.
44-
pub fn legacy_binary_path(out_dir: &std::path::Path, binary_name: &str) -> std::path::PathBuf {
45-
shared_folder_dir(out_dir).join(binary_name)
46-
}

0 commit comments

Comments
 (0)