Skip to content

Commit

Permalink
chore: cleanup & add additional file checks (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwkang1998 authored Sep 2, 2024
1 parent 3acbe33 commit 6f98ae9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 2 additions & 4 deletions crates/voyager-resolver-cairo/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ impl Compiler for VoyagerGenerator {

let (required_modules_paths, attachment_modules_data) =
self.get_reduced_project(&graph, modules_to_verify.clone())?;
println!("rmp {:?}", required_modules_paths.clone());

// Filter away packages that are external, imported from git repository & std.
let attachment_modules_data = attachment_modules_data
Expand All @@ -173,7 +172,6 @@ impl Compiler for VoyagerGenerator {
})
.map(|(k, v)| (k.clone(), v.clone()))
.collect::<HashMap<ModulePath, CairoAttachmentModule>>();
println!("amd {:?}", attachment_modules_data.clone());

let target_dir = Utf8PathBuf::from(
manifest_path
Expand Down Expand Up @@ -219,7 +217,8 @@ impl Compiler for VoyagerGenerator {

let package_name = unit.main_component().package.id.name.to_string();
let generated_crate_dir = target_dir.path_existent().unwrap().join(package_name);
//Locally run scarb build to make sure that everything compiles correctly before sending the files to voyager.

// Locally run scarb build to make sure that everything compiles correctly before sending the files to voyager.
run_scarb_build(generated_crate_dir.as_str())?;

Ok(())
Expand Down Expand Up @@ -339,7 +338,6 @@ mod tests {
use cairo_lang_filesystem::ids::{CrateLongId, Directory};
use cairo_lang_semantic::plugin::PluginSuite;
use cairo_lang_starknet::plugin::StarkNetPlugin;
use scarb_metadata::Metadata;
use std::collections::HashSet;
use std::path::PathBuf;

Expand Down
12 changes: 10 additions & 2 deletions crates/voyager-resolver-cairo/src/compiler/scarb_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,24 @@ pub fn generate_scarb_updated_files(
.packages
.retain(|package| required_packages.contains(&package.name));

for package in metadata.packages {
for package in metadata.packages.clone() {
let manifest_path = package.manifest_path;
let target_path = target_dir.path_existent()?.join(package.name);
generate_updated_scarb_toml(
manifest_path.into_std_path_buf(),
manifest_path.clone().into_std_path_buf(),
target_path.as_std_path(),
&required_packages,
&external_packages,
)?;

// Problem with this step is that sometimes the build happens faster than the Scarb.toml is actually created and detected.
// as such adding a checking step here in order to check and at the same time artificially slow down this process.
// For some weird reason this is only an issue before cairo 2.6?
if !manifest_path.exists() {
return Err(anyhow!("Files not created correctly."))
}
}

Ok(())
}

Expand Down

0 comments on commit 6f98ae9

Please sign in to comment.