@@ -52,9 +52,18 @@ fn cairo1_package_dir(version: &String) -> PathBuf {
5252 project_path ( ) . unwrap ( ) . join ( format ! ( "target/bin/cairo_package__{version}" ) )
5353}
5454
55+ /// Path to starknet-compile binary, of the specified version.
56+ fn starknet_compile_binary_path ( version : & String ) -> PathBuf {
57+ cairo1_package_dir ( version) . join ( "cairo/bin/starknet-compile" )
58+ }
59+
60+ /// Path to starknet-sierra-compile binary, of the specified version.
61+ fn starknet_sierra_compile_binary_path ( version : & String ) -> PathBuf {
62+ cairo1_package_dir ( version) . join ( "cairo/bin/starknet-sierra-compile" )
63+ }
64+
5565/// Downloads the cairo package to the local directory.
5666/// Creates the directory if it does not exist.
57- #[ allow( dead_code) ]
5867fn download_cairo_package ( version : & String ) {
5968 let directory = cairo1_package_dir ( version) ;
6069 info ! ( "Downloading Cairo package to {directory:?}." ) ;
@@ -83,6 +92,18 @@ fn download_cairo_package(version: &String) {
8392 info ! ( "Done." ) ;
8493}
8594
95+ /// Verifies that the Cairo1 package (of the given version) is available.
96+ #[ allow( dead_code) ]
97+ fn verify_cairo1_package ( version : & String , download_if_missing : bool ) {
98+ let cairo_compiler_path = starknet_compile_binary_path ( version) ;
99+ let sierra_compiler_path = starknet_sierra_compile_binary_path ( version) ;
100+ if download_if_missing && ( !cairo_compiler_path. exists ( ) || !sierra_compiler_path. exists ( ) ) {
101+ download_cairo_package ( version) ;
102+ }
103+ assert ! ( cairo_compiler_path. exists( ) , "Cairo compiler not found at {cairo_compiler_path:?}" ) ;
104+ assert ! ( sierra_compiler_path. exists( ) , "Sierra compiler not found at {sierra_compiler_path:?}" ) ;
105+ }
106+
86107/// Runs a command. If it has succeeded, it returns the command's output; otherwise, it panics with
87108/// stderr output.
88109fn run_and_verify_output ( command : & mut Command ) -> Output {
0 commit comments