Commit 8062c2ba authored by Marius Rackwitz's avatar Marius Rackwitz

[Config] Allow to opt-out of target deduplication

parent fcdc97c7
...@@ -19,6 +19,7 @@ module Pod ...@@ -19,6 +19,7 @@ module Pod
:clean => true, :clean => true,
:integrate_targets => true, :integrate_targets => true,
:deduplicate_targets => true,
:lock_pod_source => true, :lock_pod_source => true,
:new_version_message => ENV['COCOAPODS_SKIP_UPDATE_MESSAGE'].nil?, :new_version_message => ENV['COCOAPODS_SKIP_UPDATE_MESSAGE'].nil?,
...@@ -89,6 +90,11 @@ module Pod ...@@ -89,6 +90,11 @@ module Pod
attr_accessor :integrate_targets attr_accessor :integrate_targets
alias_method :integrate_targets?, :integrate_targets alias_method :integrate_targets?, :integrate_targets
# @return [Bool] Whether CocoaPods should deduplicate pod targets.
#
attr_accessor :deduplicate_targets
alias_method :deduplicate_targets?, :deduplicate_targets
# @return [Bool] Whether the installer should skip the repos update. # @return [Bool] Whether the installer should skip the repos update.
# #
attr_accessor :skip_repo_update attr_accessor :skip_repo_update
......
...@@ -284,20 +284,24 @@ module Pod ...@@ -284,20 +284,24 @@ module Pod
def generate_pod_targets(target, specs, pod_targets) def generate_pod_targets(target, specs, pod_targets)
grouped_specs = specs.group_by(&:root).values.uniq grouped_specs = specs.group_by(&:root).values.uniq
grouped_specs.map do |pod_specs| grouped_specs.map do |pod_specs|
# If there are no or already multiple pod targets with a common root, if config.deduplicate_targets?
# or the one which exists differs in the activated subspec set, then # If there are no or already multiple pod targets with a common root,
# we need to generate another pod target # or the one which exists differs in the activated subspec set, then
root_spec = pod_specs.first.root # we need to generate another pod target
common_root_pod_targets = pod_targets.select { |t| t.root_spec == root_spec } root_spec = pod_specs.first.root
if common_root_pod_targets.count != 1 || common_root_pod_targets.first.specs != pod_specs common_root_pod_targets = pod_targets.select { |t| t.root_spec == root_spec }
pod_target = generate_pod_target(target, pod_specs) if common_root_pod_targets.count != 1 || common_root_pod_targets.first.specs != pod_specs
unless common_root_pod_targets.empty? pod_target = generate_pod_target(target, pod_specs)
common_root_pod_targets.each { |t| t.scoped = true } unless common_root_pod_targets.empty?
pod_target.scoped = true common_root_pod_targets.each { |t| t.scoped = true }
pod_target.scoped = true
end
pod_target
else
common_root_pod_targets.first
end end
pod_target
else else
common_root_pod_targets.first generate_pod_target(target, pod_specs).scoped
end end
end end
end end
......
...@@ -184,6 +184,14 @@ module Pod ...@@ -184,6 +184,14 @@ module Pod
@config.should.lock_pod_source @config.should.lock_pod_source
end end
it 'integrates a user target' do
@config.should.integrate_targets
end
it 'de-duplicates targets' do
@config.should.deduplicate_targets
end
it 'returns the cache root' do it 'returns the cache root' do
@config.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods')) @config.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods'))
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