Commit cd57041f authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Resolver] Document platform compatibility predicate

parent fc1ae63a
...@@ -186,7 +186,7 @@ module Pod ...@@ -186,7 +186,7 @@ module Pod
requirement_satisfied && !( requirement_satisfied && !(
spec.version.prerelease? && spec.version.prerelease? &&
existing_vertices.flat_map(&:requirements).none? { |r| r.prerelease? || r.external_source || r.head? } existing_vertices.flat_map(&:requirements).none? { |r| r.prerelease? || r.external_source || r.head? }
) && plat?(activated, requirement, spec) ) && spec_is_platform_compatible?(activated, requirement, spec)
end end
# Sort dependencies so that the ones that are easiest to resolve are first. # Sort dependencies so that the ones that are easiest to resolve are first.
...@@ -400,14 +400,24 @@ module Pod ...@@ -400,14 +400,24 @@ module Pod
raise Informative, error.message raise Informative, error.message
end end
def plat?(dg, req, spec) # Returns whether the given spec is platform-compatible with the dependency
inc = ->(vert) do # graph, taking into account the dependency that has required the spec.
pred = vert.predecessors #
pred + pred.map(&inc).reduce(Set.new, &:&) << vert # @param [Molinillo::DependencyGraph] dependency_graph
#
# @param [Dependency] dependency
#
# @param [Specification] specification
#
# @return [Bool]
def spec_is_platform_compatible?(dependency_graph, dependency, spec)
all_predecessors = ->(vertex) do
pred = vertex.predecessors
pred + pred.map(&all_predecessors).reduce(Set.new, &:&) << vertex
end end
v = dg.vertex_named(req.name) vertex = dependency_graph.vertex_named(dependency.name)
all_inc = inc[v] predecessors = all_predecessors[vertex]
platforms_to_satisfy = all_inc.map(&:requirements).flat_map { |r| @platforms_by_dependency[r] } platforms_to_satisfy = predecessors.map(&:requirements).flat_map { |r| @platforms_by_dependency[r] }
platforms_to_satisfy.all? { |pts| spec.available_platforms.any? { |p| pts.supports?(p) } } platforms_to_satisfy.all? { |pts| spec.available_platforms.any? { |p| pts.supports?(p) } }
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment