Commit fde621d0 authored by Luke Redpath's avatar Luke Redpath

My earlier Resolver/TargetInstaller refactoring broke the handling of target-specific specs,

because previously each TargetInstaller would resolve it's specs separately.

Instead, we resolve everything in one go as before, but have the resolver return a hash of
target dependencies to resolved specifications, so when the target installers are run, we only
install the pods for that target that should be in there.

Likewise, we should only call the post-install hook of a specification with the target installers
it belongs to.
parent bf195d74
...@@ -69,7 +69,9 @@ module Pod ...@@ -69,7 +69,9 @@ module Pod
puts "Generating support files" unless config.silent? puts "Generating support files" unless config.silent?
target_installers.each do |target_installer| target_installers.each do |target_installer|
target_installer.install!(pods, sandbox) target_specs = build_specifications_for_target(target_installer.target_definition)
pods_for_target = pods.select { |pod| target_specs.include?(pod.specification) }
target_installer.install!(pods_for_target, sandbox)
end end
generate_lock_file!(pods) generate_lock_file!(pods)
...@@ -87,7 +89,9 @@ module Pod ...@@ -87,7 +89,9 @@ module Pod
# to the spec post install hook. # to the spec post install hook.
target_installers.each do |target_installer| target_installers.each do |target_installer|
build_specifications.each { |spec| spec.post_install(target_installer) } build_specifications_for_target(target_installer.target_definition).each do |spec|
spec.post_install(target_installer)
end
end end
@podfile.post_install!(self) @podfile.post_install!(self)
...@@ -123,8 +127,12 @@ module Pod ...@@ -123,8 +127,12 @@ module Pod
end end
end end
def dependent_specifications_for_each_target_definition
@dependent_specifications_for_each_target_definition ||= Resolver.new(@podfile, @sandbox).resolve
end
def dependent_specifications def dependent_specifications
@dependent_specifications ||= Resolver.new(@podfile, @sandbox).resolve dependent_specifications_for_each_target_definition.values.flatten
end end
def build_specifications def build_specifications
...@@ -132,6 +140,10 @@ module Pod ...@@ -132,6 +140,10 @@ module Pod
spec.wrapper? || spec.defined_in_set.only_part_of_other_pod? spec.wrapper? || spec.defined_in_set.only_part_of_other_pod?
end end
end end
def build_specifications_for_target(target_definition)
dependent_specifications_for_each_target_definition[target_definition]
end
def download_only_specifications def download_only_specifications
dependent_specifications - build_specifications dependent_specifications - build_specifications
......
...@@ -6,15 +6,18 @@ module Pod ...@@ -6,15 +6,18 @@ module Pod
end end
def resolve def resolve
@sets, @loaded_spec_names, @specs = [], [], [] @podfile.target_definitions.values.inject({}) do |result, target_definition|
find_dependency_sets(@podfile) @sets, @loaded_spec_names, @specs = [], [], []
@specs.sort_by(&:name) find_dependency_sets(@podfile, target_definition.dependencies)
result[target_definition] = @specs.sort_by(&:name)
result
end
end end
# this can be called with anything that has dependencies # this can be called with anything that has dependencies
# e.g. a Specification or a Podfile. # e.g. a Specification or a Podfile.
def find_dependency_sets(has_dependencies) def find_dependency_sets(has_dependencies, dependency_subset = nil)
has_dependencies.dependencies.each do |dependency| (dependency_subset || has_dependencies.dependencies).each do |dependency|
set = find_dependency_set(dependency) set = find_dependency_set(dependency)
set.required_by(has_dependencies) set.required_by(has_dependencies)
unless @loaded_spec_names.include?(dependency.name) unless @loaded_spec_names.include?(dependency.name)
......
...@@ -39,7 +39,7 @@ describe "Pod::Resolver" do ...@@ -39,7 +39,7 @@ describe "Pod::Resolver" do
end end
it "returns all specs needed for the dependency" do it "returns all specs needed for the dependency" do
specs = Pod::Resolver.new(@podfile, stub('sandbox')).resolve specs = Pod::Resolver.new(@podfile, stub('sandbox')).resolve.values.flatten
specs.map(&:class).uniq.should == [Pod::Specification] specs.map(&:class).uniq.should == [Pod::Specification]
specs.map(&:name).sort.should == %w{ ASIHTTPRequest ASIWebPageRequest Reachability } specs.map(&:name).sort.should == %w{ ASIHTTPRequest ASIWebPageRequest Reachability }
end end
...@@ -77,7 +77,7 @@ describe "Pod::Resolver" do ...@@ -77,7 +77,7 @@ describe "Pod::Resolver" do
end end
config.rootspec = @podfile config.rootspec = @podfile
resolver = Pod::Resolver.new(@podfile, stub('sandbox')) resolver = Pod::Resolver.new(@podfile, stub('sandbox'))
resolver.resolve.map(&:name).sort.should == %w{ LibComponentLogging-Core LibComponentLogging-NSLog RestKit RestKit/Network RestKit/ObjectMapping } resolver.resolve.values.flatten.map(&:name).sort.should == %w{ LibComponentLogging-Core LibComponentLogging-NSLog RestKit RestKit/Network RestKit/ObjectMapping }
end end
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