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

Merge pull request #2760 from CocoaPods/seg-from-subspec-dependencies

[WIP] [Resolver] Add filtering for subspecs included via subspec_dependencies
parents 4cdea76a 2c0df3a0
......@@ -15,7 +15,7 @@ gem 'json', '1.7.7'
group :development do
cp_gem 'claide', 'CLAide'
cp_gem 'cocoapods-core', 'Core'
cp_gem 'cocoapods-core', 'Core', 'seg-from-subspec-dependencies'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
cp_gem 'cocoapods-trunk', 'cocoapods-trunk'
......@@ -44,4 +44,3 @@ group :debugging do
gem 'pry'
gem 'ruby-prof'
end
......@@ -7,8 +7,8 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision: 8b554d8dd184e75bb79dcc86a7056e9fef35e952
branch: master
revision: afa6cd5ea769a8044d36a002f7e1e2ec2710da00
branch: seg-from-subspec-dependencies
specs:
cocoapods-core (0.34.4)
activesupport (>= 3.2.15)
......@@ -17,7 +17,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Molinillo.git
revision: 67d09200c8baca9547f54a0145b405c658e0ba07
revision: e86cec392a75c577f2c803d8cc87debe41a9bdbe
branch: master
specs:
molinillo (0.1.0)
......
......@@ -69,8 +69,9 @@ module Pod
podfile.target_definition_list.each do |target|
specs = target.dependencies.map(&:name).map do |name|
node = @activated.vertex_named(name)
(node.recursive_successors << node).to_a
valid_dependencies_for_target_from_node(target, node) << node
end
specs_by_target[target] = specs.
flatten.
map(&:payload).
......@@ -126,7 +127,7 @@ module Pod
def dependencies_for(specification)
specification.all_dependencies.map do |dependency|
if dependency.root_name == Specification.root_name(specification.name)
Dependency.new(dependency.name, specification.version)
dependency.dup.tap { |d| d.specific_version = specification.version }
else
dependency
end
......@@ -342,5 +343,38 @@ module Pod
"a minimum requirement of #{spec.available_platforms.join(' - ')}."
end
end
# Returns the target-appropriate nodes that are `successors` of `node`,
# rejecting those that are {Dependency#from_subspec_dependency?} and have
# and incompatible platform.
#
# @return [Array<Molinillo::DependencyGraph::Vertex>]
# An array of target-appropriate nodes whose `payload`s are
# dependencies for `target`.
#
def valid_dependencies_for_target_from_node(target, node)
dependency_nodes = node.outgoing_edges.select do |edge|
edge_is_valid_for_target?(edge, target)
end.map(&:destination)
dependency_nodes + dependency_nodes.flat_map { |n| valid_dependencies_for_target_from_node(target, n) }
end
# Whether the given `edge` should be followed to find dependencies for the
# given `target`.
#
# @note At the moment, this method only checks whether the edge's
# requirements are normal dependencies _or_ whether they are
# dependencies that come from {Specification#subspec_dependencies}
# and, if so, that their platforms are compatible with the target's.
#
# @return [Bool]
#
def edge_is_valid_for_target?(edge, target)
edge.requirements.any? do |dependency|
!dependency.from_subspec_dependency? ||
edge.destination.payload.available_platforms.any? { |p| target.platform.supports?(p) }
end
end
end
end
......@@ -175,6 +175,23 @@ module Pod
e.message.should.match(/platform .* not compatible/)
end
it 'excludes dependencies from `Specification#subspec_dependencies` ' \
'with incompatible platforms without raising' do
@podfile = Podfile.new do
platform :osx, '10.10'
pod 'AFNetworking', '2.4.1' # Has an 'AFNetworking/UIKit' iOS-only default subspec
end
resolver = Resolver.new(config.sandbox, @podfile, empty_graph, SourcesManager.all)
resolver.resolve.values.flatten.map(&:to_s).sort.should == [
"AFNetworking (2.4.1)",
"AFNetworking/NSURLConnection (2.4.1)",
"AFNetworking/NSURLSession (2.4.1)",
"AFNetworking/Reachability (2.4.1)",
"AFNetworking/Security (2.4.1)",
"AFNetworking/Serialization (2.4.1)",
]
end
it 'raises if unable to find a specification' do
Specification.any_instance.stubs(:all_dependencies).returns([Dependency.new('Windows')])
message = should.raise Informative do
......
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