Skip to content

Commit

Permalink
Merge branch 'saudi/fix-dependency-order-determinism' into 'main'
Browse files Browse the repository at this point in the history
Fix determinism when configs inherit properties from their dependencies, during Link stage

See merge request Sharpmake/sharpmake!551
  • Loading branch information
jspelletier committed Sep 10, 2024
2 parents 1e5e327 + 7252ea0 commit c7f5bb5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Sharpmake/Project.Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3284,6 +3284,18 @@ private static int SortConfigurationForLink(Configuration l, Configuration r)
return string.Compare(l.Project.FullClassName, r.Project.FullClassName, StringComparison.Ordinal);
}

private static int SortDotNetDependencyForLink(DotNetDependency l, DotNetDependency r)
{
return SortConfigurationForLink(l.Configuration, r.Configuration);
}
private static int SortDependencyForLink((DependencyNode, DependencyType) l, (DependencyNode, DependencyType) r)
{
int cmpType = l.Item2.CompareTo(r.Item2);
if (cmpType != 0)
return -cmpType; // reverse order (public first, private last)
return SortConfigurationForLink(l.Item1._configuration, r.Item1._configuration);
}

internal class DependencyNode
{
internal DependencyNode(Configuration inConfiguration, DependencySetting inDependencySetting)
Expand Down Expand Up @@ -3815,6 +3827,10 @@ IConfigurationTasks GetConfigurationTasks(Platform platform)

DotNetPublicDependencies = resolvedDotNetPublicDependencies.ToList();
DotNetPrivateDependencies = resolvedDotNetPrivateDependencies.ToList();

DotNetPublicDependencies.Sort(SortDotNetDependencyForLink);
DotNetPrivateDependencies.Sort(SortDotNetDependencyForLink);

if (configurationsSwappedToDll is not null)
{
ConfigurationsSwappedToDll = configurationsSwappedToDll;
Expand Down Expand Up @@ -3905,6 +3921,7 @@ static private DependencyNode BuildDependencyNodeTree(Builder builder, Configura
visiting.Push(childNode);
}
}
visitedNode._childNodes.Sort(SortDependencyForLink);
}

return rootNode;
Expand Down

0 comments on commit c7f5bb5

Please sign in to comment.