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

Merge pull request #4096 from CocoaPods/seg-transitive-circular

[Analyzer] Dont create cycles when computing transitive dependencies
parents 9cede39c 186d0bba
...@@ -13,6 +13,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -13,6 +13,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#3967](https://github.com/CocoaPods/CocoaPods/issues/3967) [#3967](https://github.com/CocoaPods/CocoaPods/issues/3967)
* Computing the set of transitive dependencies for a pod target,
even if the target is scoped, will no longer smash the stack.
[Samuel Giddins](https://github.com/segiddins)
[#4092](https://github.com/CocoaPods/CocoaPods/issues/4092)
## 0.39.0.beta.3 (2015-08-28) ## 0.39.0.beta.3 (2015-08-28)
......
...@@ -314,12 +314,15 @@ module Pod ...@@ -314,12 +314,15 @@ module Pod
end end
end end
else else
specs_by_target.flat_map do |target_definition, specs| pod_targets = specs_by_target.flat_map do |target_definition, specs|
grouped_specs = specs.group_by.group_by(&:root).values.uniq grouped_specs = specs.group_by.group_by(&:root).values.uniq
grouped_specs.flat_map do |pod_specs| grouped_specs.flat_map do |pod_specs|
generate_pod_target([target_definition], pod_specs, :scoped => true) generate_pod_target([target_definition], pod_specs, :scoped => true)
end end
end end
pod_targets.each do |target|
target.dependent_targets = transitive_dependencies_for_pod_target(target, pod_targets)
end
end end
end end
...@@ -340,12 +343,14 @@ module Pod ...@@ -340,12 +343,14 @@ module Pod
def transitive_dependencies_for_pod_target(pod_target, targets) def transitive_dependencies_for_pod_target(pod_target, targets)
if targets.any? if targets.any?
dependent_targets = pod_target.dependencies.flat_map do |dep| dependent_targets = pod_target.dependencies.flat_map do |dep|
next [] if pod_target.pod_name == dep
targets.select { |t| t.pod_name == dep } targets.select { |t| t.pod_name == dep }
end end
remaining_targets = targets - dependent_targets remaining_targets = targets - dependent_targets
dependent_targets + dependent_targets.flat_map do |target| dependent_targets += dependent_targets.flat_map do |target|
transitive_dependencies_for_pod_target(target, remaining_targets) transitive_dependencies_for_pod_target(target, remaining_targets)
end end
dependent_targets.uniq
else else
[] []
end end
......
...@@ -66,7 +66,7 @@ module Pod ...@@ -66,7 +66,7 @@ module Pod
target.user_build_configurations = user_build_configurations target.user_build_configurations = user_build_configurations
target.native_target = native_target target.native_target = native_target
target.archs = archs target.archs = archs
target.dependent_targets = dependent_targets.map(&:scoped) target.dependent_targets = dependent_targets.flat_map(&:scoped)
end end
end end
end end
......
...@@ -116,6 +116,29 @@ module Pod ...@@ -116,6 +116,29 @@ module Pod
target.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
end end
it 'generates the set of dependent pod targets' do
@podfile = Pod::Podfile.new do
platform :ios, '8.0'
xcodeproj 'SampleProject/SampleProject'
pod 'RestKit', '~> 0.23.0'
target 'TestRunner' do
pod 'RestKit/Testing', '~> 0.23.0'
end
end
@analyzer = Pod::Installer::Analyzer.new(config.sandbox, @podfile, nil)
target = @analyzer.analyze.targets.first
restkit_target = target.pod_targets.find { |pt| pt.pod_name == 'RestKit' }
restkit_target.should.be.scoped
restkit_target.dependent_targets.map(&:pod_name).sort.should == %w(
AFNetworking
ISO8601DateFormatterValueTransformer
RKValueTransformers
SOCKit
TransitionKit
)
restkit_target.dependent_targets.all?(&:scoped).should.be.true
end
describe 'deduplication' do describe 'deduplication' do
before do before do
repos = [fixture('spec-repos/test_repo'), fixture('spec-repos/master')] repos = [fixture('spec-repos/test_repo'), fixture('spec-repos/master')]
......
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