From 264bf1714357b3cbb048f8d9d6f502180aa26a1d Mon Sep 17 00:00:00 2001 From: Avi Cohen Date: Wed, 13 Nov 2024 19:40:08 +0200 Subject: [PATCH] Fix review comments --- crates/bin/starknet-native-compile/build.rs | 22 ------------------- .../bin/starknet-native-compile/src/main.rs | 12 +++------- 2 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 crates/bin/starknet-native-compile/build.rs diff --git a/crates/bin/starknet-native-compile/build.rs b/crates/bin/starknet-native-compile/build.rs deleted file mode 100644 index 64acd66862..0000000000 --- a/crates/bin/starknet-native-compile/build.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::path::Path; - -// This build script sets the env var CAIRO_NATIVE_RUNTIME_LIBRARY to an absolute path to the runtime library. -fn main() { - println!("cargo:rerun-if-env-changed=CAIRO_NATIVE_RUNTIME_LIBRARY"); - if env!("CAIRO_NATIVE_RUNTIME_LIBRARY").starts_with('/') { - // The runtime library path is already absolute, no need to set the env var. - return; - } - let out_dir = Path::new( - &std::env::var("OUT_DIR").expect("Failed to get the OUT_DIR environment variable"), - ) - .to_path_buf(); - - let blockifier_path = out_dir - .ancestors() - .nth(3) - .expect("Failed to navigate up three levels from OUT_DIR") - .to_path_buf(); - let runtime_library_abosulte_path = blockifier_path.join(env!("CAIRO_NATIVE_RUNTIME_LIBRARY")); - std::env::set_var("CAIRO_NATIVE_RUNTIME_LIBRARY", runtime_library_abosulte_path); -} diff --git a/crates/bin/starknet-native-compile/src/main.rs b/crates/bin/starknet-native-compile/src/main.rs index 9834739b12..0d6db5b17d 100644 --- a/crates/bin/starknet-native-compile/src/main.rs +++ b/crates/bin/starknet-native-compile/src/main.rs @@ -13,23 +13,18 @@ mod utils; struct Args { /// The path of the Sierra file to compile. path: PathBuf, - /// The output file name (default: output.so). - output: Option, + /// The output file path. + output: PathBuf, } -const DEFAULT_OUTPUT_FILE: &str = "./output.so"; - fn main() { // TODO(Avi, 01/12/2024): Find a way to restrict time, memory and file size during compilation. let args = Args::parse(); let path = args.path; - let output = args.output.unwrap_or_else(|| DEFAULT_OUTPUT_FILE.to_string()); + let output = args.output; - println!("Loading Sierra program from file: {:?}", &path); let sierra_program = load_sierra_program_from_file(&path); - println!("Compiling Sierra program into file {:?}", &output); - let start = std::time::Instant::now(); let mut contract_executor = AotContractExecutor::new(&sierra_program, OptLevel::default()) .unwrap_or_else(|err| { eprintln!("Error compiling Sierra program: {}", err); @@ -39,5 +34,4 @@ fn main() { eprintln!("Error saving compiled program: {}", err); process::exit(1); }); - println!("Compilation successful. Elapsed: {:?}", start.elapsed()); }