Skip to content

Commit

Permalink
Fix dep version for corelib
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr committed Oct 1, 2024
1 parent ea00bc2 commit da36090
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 4 additions & 2 deletions extensions/scarb-doc/src/metadata/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ fn get_crate_settings_for_package(
.iter()
.find(|package| package.name == compilation_unit_metadata_component.name)
.map(|package| package.version.clone());

let version = (dependency.name == *CORELIB_CRATE_NAME)
.then_some(version)
.flatten();
(dependency.name.clone(), DependencySettings { version })
})
})
Expand All @@ -162,7 +164,7 @@ fn get_crate_settings_for_package(
dependencies.insert(
package.name.clone(),
DependencySettings {
version: Some(package.version.clone()),
version: (package.name != *CORELIB_CRATE_NAME).then_some(package.version.clone()),
},
);

Expand Down
8 changes: 5 additions & 3 deletions extensions/scarb-snforge-test-collector/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{anyhow, ensure, Context, Result};
use cairo_lang_filesystem::cfg::{Cfg, CfgSet};
use cairo_lang_filesystem::db::{
CrateSettings, DependencySettings, Edition, ExperimentalFeaturesConfig,
CrateSettings, DependencySettings, Edition, ExperimentalFeaturesConfig, CORELIB_CRATE_NAME,
};
use cairo_lang_project::AllCratesConfig;
use cairo_lang_utils::ordered_hash_map::OrderedHashMap;
Expand Down Expand Up @@ -249,7 +249,9 @@ fn get_crate_settings_for_package(
.iter()
.find(|package| package.name == compilation_unit_metadata_component.name)
.map(|package| package.version.clone());

let version = (dependency.name == *CORELIB_CRATE_NAME)
.then_some(version)
.flatten();
(dependency.name.clone(), DependencySettings { version })
})
})
Expand All @@ -259,7 +261,7 @@ fn get_crate_settings_for_package(
dependencies.insert(
package.name.clone(),
DependencySettings {
version: Some(package.version.clone()),
version: (package.name != *CORELIB_CRATE_NAME).then_some(package.version.clone()),
},
);

Expand Down
8 changes: 6 additions & 2 deletions scarb/src/compiler/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use cairo_lang_defs::ids::ModuleId;
use cairo_lang_defs::plugin::MacroPlugin;
use cairo_lang_filesystem::db::{
AsFilesGroupMut, CrateSettings, DependencySettings, FilesGroup, FilesGroupEx,
CORELIB_CRATE_NAME,
};
use cairo_lang_filesystem::ids::{CrateLongId, Directory};
use cairo_lang_utils::ordered_hash_map::OrderedHashMap;
Expand Down Expand Up @@ -174,7 +175,9 @@ fn build_project_config(unit: &CairoCompilationUnit) -> Result<ProjectConfig> {
(
compilation_unit_component.package.id.name.to_string(),
DependencySettings {
version: Some(compilation_unit_component.package.id.version.clone()),
version: (compilation_unit_component.package.id.name.to_string()
!= *CORELIB_CRATE_NAME)
.then_some(compilation_unit_component.package.id.version.clone()),
},
)
})
Expand All @@ -184,7 +187,8 @@ fn build_project_config(unit: &CairoCompilationUnit) -> Result<ProjectConfig> {
dependencies.insert(
component.package.id.name.to_string(),
DependencySettings {
version: Some(component.package.id.version.clone()),
version: (component.package.id.name.to_string() != *CORELIB_CRATE_NAME)
.then_some(component.package.id.version.clone()),
},
);

Expand Down

0 comments on commit da36090

Please sign in to comment.