Skip to content

Commit

Permalink
chore(starknet_sierra_compile): path cleanups
Browse files Browse the repository at this point in the history
commit-id:d3f4e29f
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 15, 2024
1 parent 89ccd71 commit 21466a6
Showing 2 changed files with 8 additions and 15 deletions.
14 changes: 5 additions & 9 deletions crates/starknet_sierra_compile/build.rs
Original file line number Diff line number Diff line change
@@ -40,13 +40,16 @@ fn install_starknet_native_compile() {
let binary_name = CAIRO_NATIVE_BINARY_NAME;
let required_version = REQUIRED_CAIRO_NATIVE_VERSION;

let repo_root_dir =
infra_utils::path::project_path().expect("Should be able to get the project path");

// Set the runtime library path. This is required for Cairo native compilation.
let runtime_library_path = repo_root_dir()
let runtime_library_path = repo_root_dir
.join("crates/blockifier/cairo_native/target/release/libcairo_native_runtime.a");
println!("cargo:rustc-env=CAIRO_NATIVE_RUNTIME_LIBRARY={}", runtime_library_path.display());
println!("cargo:rerun-if-env-changed=CAIRO_NATIVE_RUNTIME_LIBRARY");

let starknet_native_compile_crate_path = repo_root_dir().join("crates/bin").join(binary_name);
let starknet_native_compile_crate_path = repo_root_dir.join("crates/bin").join(binary_name);
let starknet_native_compile_crate_path_str = starknet_native_compile_crate_path
.to_str()
.expect("Failed to convert the crate path to str");
@@ -126,10 +129,3 @@ fn out_dir() -> std::path::PathBuf {
.expect("Failed to get the build time OUT_DIR environment variable")
.into()
}

#[cfg(feature = "cairo_native")]
fn repo_root_dir() -> std::path::PathBuf {
std::path::Path::new(infra_utils::compile_time_cargo_manifest_dir!())
.join("../..")
.to_path_buf()
}
9 changes: 3 additions & 6 deletions crates/starknet_sierra_compile/src/command_line_compiler.rs
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@ use cairo_lang_starknet_classes::contract_class::ContractClass;
#[cfg(feature = "cairo_native")]
use cairo_native::executor::AotContractExecutor;
use tempfile::NamedTempFile;
#[cfg(feature = "cairo_native")]
use tempfile::TempDir;

use crate::config::SierraToCasmCompilationConfig;
use crate::constants::CAIRO_LANG_BINARY_NAME;
@@ -66,10 +64,9 @@ impl SierraToNativeCompiler for CommandLineCompiler {
contract_class: ContractClass,
) -> Result<AotContractExecutor, CompilationUtilError> {
let compiler_binary_path = &self.path_to_starknet_native_compile_binary;
let output_dir =
TempDir::new().expect("Failed to create temporary compilation output directory.");
let output_file = output_dir.path().join("output.so");
let output_file_path = output_file.to_str().ok_or(

let output_file = NamedTempFile::new()?;
let output_file_path = output_file.path().to_str().ok_or(
CompilationUtilError::UnexpectedError("Failed to get output file path".to_owned()),
)?;
let additional_args = [output_file_path];

0 comments on commit 21466a6

Please sign in to comment.