@@ -44,9 +44,18 @@ fn cairo1_package_dir(version: &String) -> PathBuf {
4444 project_path ( ) . unwrap ( ) . join ( format ! ( "target/bin/cairo_package__{version}" ) )
4545}
4646
47+ /// Path to starknet-compile binary, of the specified version.
48+ fn starknet_compile_binary_path ( version : & String ) -> PathBuf {
49+ cairo1_package_dir ( version) . join ( "cairo/bin/starknet-compile" )
50+ }
51+
52+ /// Path to starknet-sierra-compile binary, of the specified version.
53+ fn starknet_sierra_compile_binary_path ( version : & String ) -> PathBuf {
54+ cairo1_package_dir ( version) . join ( "cairo/bin/starknet-sierra-compile" )
55+ }
56+
4757/// Downloads the cairo package to the local directory.
4858/// Creates the directory if it does not exist.
49- #[ allow( dead_code) ]
5059async fn download_cairo_package ( version : & String ) {
5160 let directory = cairo1_package_dir ( version) ;
5261 info ! ( "Downloading Cairo package to {directory:?}." ) ;
@@ -72,6 +81,22 @@ async fn download_cairo_package(version: &String) {
7281 info ! ( "Done." ) ;
7382}
7483
84+ fn cairo1_package_exists ( version : & String ) -> bool {
85+ let cairo_compiler_path = starknet_compile_binary_path ( version) ;
86+ let sierra_compiler_path = starknet_sierra_compile_binary_path ( version) ;
87+ cairo_compiler_path. exists ( ) && sierra_compiler_path. exists ( )
88+ }
89+
90+ /// Verifies that the Cairo1 package (of the given version) is available.
91+ /// Attempts to download it if not.
92+ #[ allow( dead_code) ]
93+ async fn verify_cairo1_package ( version : & String ) {
94+ if !cairo1_package_exists ( version) {
95+ download_cairo_package ( version) . await ;
96+ }
97+ assert ! ( cairo1_package_exists( version) ) ;
98+ }
99+
75100/// Runs a command. If it has succeeded, it returns the command's output; otherwise, it panics with
76101/// stderr output.
77102fn run_and_verify_output ( command : & mut Command ) -> Output {
0 commit comments