Skip to content

Commit dff8e6e

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 7c87ee5 commit dff8e6e

5 files changed

Lines changed: 8 additions & 93 deletions

File tree

.github/workflows/upload_artifacts_workflow.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,12 @@ jobs:
144144
path: "target/release/native_blockifier.pypy39-pp73-x86_64-linux-gnu.so"
145145
destination: "native_blockifier_artifacts/${{ env.SHORT_HASH }}/release/"
146146

147+
- name: Copy starknet-native-compile for upload
148+
run: cp "$HOME/.cargo/bin/starknet-native-compile" target/release/starknet-native-compile
149+
147150
- name: Upload starknet-native-compile to GCP
148151
id: upload_snc_file
149152
uses: "google-github-actions/upload-cloud-storage@v2"
150153
with:
151-
path: "target/release/shared_executables/starknet-native-compile"
154+
path: "target/release/starknet-native-compile"
152155
destination: "native_blockifier_artifacts/${{ env.SHORT_HASH }}/release/"

BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Export the built artifact to allow local builds.
22
exports_files([
33
"target/release/libnative_blockifier.so",
4-
"target/release/shared_executables/starknet-native-compile",
4+
"target/release/starknet-native-compile",
55
"target/debug/starknet_committer_and_os_cli",
66
"target/release/starknet_committer_and_os_cli",
77
"target/x86_64-unknown-linux-musl/debug/starknet_committer_and_os_cli",

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
pub fn verify_compiler_binary(binary_path: &Path, required_version: &str) {
Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
1-
// Note: This module includes path resolution functions that are needed during build and run times.
2-
// It must not contain functionality that is available in only in one of these modes. Specifically,
3-
// it must avoid relying on env variables such as 'CARGO_*' or 'OUT_DIR'.
4-
5-
fn target_dir(out_dir: &std::path::Path) -> std::path::PathBuf {
6-
out_dir
7-
.ancestors()
8-
.nth(3)
9-
.expect("Failed to navigate up three levels from OUT_DIR")
10-
.to_path_buf()
11-
}
12-
13-
pub fn shared_folder_dir(out_dir: &std::path::Path) -> std::path::PathBuf {
14-
target_dir(out_dir).join("shared_executables")
15-
}
1+
use std::path::PathBuf;
162

173
/// Returns the binary name as a PathBuf. `Command::new` will find it in PATH.
18-
pub fn binary_path(binary_name: &str) -> std::path::PathBuf {
19-
std::path::PathBuf::from(binary_name)
20-
}
21-
22-
// TODO(Avi): Remove once build.rs callers are gone.
23-
pub fn legacy_binary_path(out_dir: &std::path::Path, binary_name: &str) -> std::path::PathBuf {
24-
shared_folder_dir(out_dir).join(binary_name)
4+
pub fn binary_path(binary_name: &str) -> PathBuf {
5+
PathBuf::from(binary_name)
256
}

0 commit comments

Comments
 (0)