Skip to content

Commit

Permalink
Move check_cairo_version_compatibility to generate_compilation_units
Browse files Browse the repository at this point in the history
  • Loading branch information
DelevoXDG committed Oct 25, 2024
1 parent 9a3f425 commit badc59b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
18 changes: 7 additions & 11 deletions scarb/src/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,13 @@ pub fn generate_compilation_units(
.filter(|member| !member.is_cairo_plugin())
.collect_vec();
validate_features(&members, enabled_features)?;
check_cairo_version_compatibility(&members, ws, ignore_cairo_version)?;

for member in members {
units.extend(generate_cairo_compilation_units(
&member,
resolve,
enabled_features,
ignore_cairo_version,
ws,
)?);
}
Expand Down Expand Up @@ -237,7 +238,7 @@ fn generate_cairo_compilation_units(
member: &Package,
resolve: &WorkspaceResolve,
enabled_features: &FeaturesOpts,
ignore_cairo_version: bool,

ws: &Workspace<'_>,
) -> Result<Vec<CompilationUnit>> {
let profile = ws.current_profile()?;
Expand All @@ -258,7 +259,6 @@ fn generate_cairo_compilation_units(
member,
profile.clone(),
enabled_features,
ignore_cairo_version,
&mut solution,
)?))
})
Expand All @@ -274,7 +274,6 @@ fn generate_cairo_compilation_units(
member,
profile.clone(),
enabled_features,
ignore_cairo_version,
&mut solution,
)?))
})
Expand All @@ -291,11 +290,11 @@ fn cairo_compilation_unit_for_target(
member: &Package,
profile: Profile,
enabled_features: &FeaturesOpts,
ignore_cairo_version: bool,

solution: &mut PackageSolutionCollector<'_>,
) -> Result<CairoCompilationUnit> {
let member_target = member_targets.first().cloned().unwrap();
solution.collect(&member_target.kind, ignore_cairo_version)?;
solution.collect(&member_target.kind)?;
let packages = solution.packages.as_ref().unwrap();
let cairo_plugins = solution.cairo_plugins.as_ref().unwrap();

Expand Down Expand Up @@ -485,15 +484,15 @@ impl<'a> PackageSolutionCollector<'a> {
}
}

pub fn collect(&mut self, target_kind: &TargetKind, ignore_cairo_version: bool) -> Result<()> {
pub fn collect(&mut self, target_kind: &TargetKind) -> Result<()> {
// Do not traverse graph for each target of the same kind.
if !self
.target_kind
.as_ref()
.map(|tk| tk == target_kind)
.unwrap_or(false)
{
let (p, c) = self.pull_from_graph(target_kind, ignore_cairo_version)?;
let (p, c) = self.pull_from_graph(target_kind)?;
self.packages = Some(p.clone());
self.cairo_plugins = Some(c.clone());
self.target_kind = Some(target_kind.clone());
Expand All @@ -504,7 +503,6 @@ impl<'a> PackageSolutionCollector<'a> {
fn pull_from_graph(
&mut self,
target_kind: &TargetKind,
ignore_cairo_version: bool,
) -> Result<(Vec<Package>, Vec<CompilationUnitCairoPlugin>)> {
let mut classes = self
.resolve
Expand Down Expand Up @@ -541,8 +539,6 @@ impl<'a> PackageSolutionCollector<'a> {
assert!(!packages.is_empty());
assert_eq!(packages[0].id, self.member.id);

check_cairo_version_compatibility(&packages, self.ws, ignore_cairo_version)?;

// Print warnings for dependencies that are not usable.
let other = classes.remove(&PackageClass::Other).unwrap_or_default();
for pkg in other {
Expand Down
4 changes: 0 additions & 4 deletions scarb/tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,6 @@ fn compile_ignore_cairo_version() {
Cairo version required: ^33.33.0
Cairo version of Scarb: [..]
warn: the required Cairo version of package hello is not compatible with current version
Cairo version required: ^33.33.0
Cairo version of Scarb: [..]
[..] Checking hello v0.1.0 ([..]Scarb.toml)
[..] Finished checking `dev` profile target(s) in [..]
"#});
Expand Down

0 comments on commit badc59b

Please sign in to comment.