@@ -42,9 +42,18 @@ fn cairo1_package_dir(version: &String) -> PathBuf {
4242 project_path ( ) . unwrap ( ) . join ( format ! ( "target/bin/cairo_package__{version}" ) )
4343}
4444
45+ /// Path to starknet-compile binary, of the specified version.
46+ fn starknet_compile_binary_path ( version : & String ) -> PathBuf {
47+ cairo1_package_dir ( version) . join ( "cairo/bin/starknet-compile" )
48+ }
49+
50+ /// Path to starknet-sierra-compile binary, of the specified version.
51+ fn starknet_sierra_compile_binary_path ( version : & String ) -> PathBuf {
52+ cairo1_package_dir ( version) . join ( "cairo/bin/starknet-sierra-compile" )
53+ }
54+
4555/// Downloads the cairo package to the local directory.
4656/// Creates the directory if it does not exist.
47- #[ allow( dead_code) ]
4857async fn download_cairo_package ( version : & String ) {
4958 let directory = cairo1_package_dir ( version) ;
5059 info ! ( "Downloading Cairo package to {directory:?}." ) ;
@@ -70,6 +79,18 @@ async fn download_cairo_package(version: &String) {
7079 info ! ( "Done." ) ;
7180}
7281
82+ /// Verifies that the Cairo1 package (of the given version) is available.
83+ #[ allow( dead_code) ]
84+ async fn verify_cairo1_package ( version : & String , download_if_missing : bool ) {
85+ let cairo_compiler_path = starknet_compile_binary_path ( version) ;
86+ let sierra_compiler_path = starknet_sierra_compile_binary_path ( version) ;
87+ if download_if_missing && ( !cairo_compiler_path. exists ( ) || !sierra_compiler_path. exists ( ) ) {
88+ download_cairo_package ( version) . await ;
89+ }
90+ assert ! ( cairo_compiler_path. exists( ) , "Cairo compiler not found at {cairo_compiler_path:?}" ) ;
91+ assert ! ( sierra_compiler_path. exists( ) , "Sierra compiler not found at {sierra_compiler_path:?}" ) ;
92+ }
93+
7394/// Runs a command. If it has succeeded, it returns the command's output; otherwise, it panics with
7495/// stderr output.
7596fn run_and_verify_output ( command : & mut Command ) -> Output {
0 commit comments