Commit c5f93ced authored by Marius Rackwitz's avatar Marius Rackwitz

[Refactor] Extracted #pod_targets_for_build_configuration from…

[Refactor] Extracted #pod_targets_for_build_configuration from AggregateTarget#pod_targets_for_build_configuration
parent 9eff0792
...@@ -48,6 +48,7 @@ module Pod ...@@ -48,6 +48,7 @@ module Pod
# #
def generate def generate
header_search_path_flags = target.sandbox.public_headers.search_paths(target.platform) header_search_path_flags = target.sandbox.public_headers.search_paths(target.platform)
pod_targets = target.pod_targets_for_build_configuration(@configuration_name)
config = { config = {
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target), 'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'OTHER_LIBTOOLFLAGS' => '$(OTHER_LDFLAGS)', 'OTHER_LIBTOOLFLAGS' => '$(OTHER_LDFLAGS)',
...@@ -69,9 +70,7 @@ module Pod ...@@ -69,9 +70,7 @@ module Pod
XCConfigHelper.add_target_specific_settings(target, @xcconfig) XCConfigHelper.add_target_specific_settings(target, @xcconfig)
target.pod_targets.each do |pod_target| pod_targets.each do |pod_target|
next unless pod_target.include_in_build_config?(@configuration_name)
pod_target.file_accessors.each do |file_accessor| pod_target.file_accessors.each do |file_accessor|
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig) XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
file_accessor.vendored_frameworks.each do |vendored_framework| file_accessor.vendored_frameworks.each do |vendored_framework|
......
...@@ -79,6 +79,18 @@ module Pod ...@@ -79,6 +79,18 @@ module Pod
# #
attr_accessor :pod_targets attr_accessor :pod_targets
# @param [String] build_configuration The build configuration for which the
# the pod targets should be returned.
#
# @return [Array<PodTarget>] the pod targets for the given build
# configuration.
#
def pod_targets_for_build_configuration(build_configuration)
pod_targets.select do |pod_target|
pod_target.include_in_build_config?(build_configuration)
end
end
# @return [Array<Specification>] The specifications used by this aggregate target. # @return [Array<Specification>] The specifications used by this aggregate target.
# #
def specs def specs
...@@ -91,9 +103,8 @@ module Pod ...@@ -91,9 +103,8 @@ module Pod
def specs_by_build_configuration def specs_by_build_configuration
result = {} result = {}
user_build_configurations.keys.each do |build_configuration| user_build_configurations.keys.each do |build_configuration|
result[build_configuration] = pod_targets.select do |pod_target| result[build_configuration] = pod_targets_for_build_configuration(build_configuration).
pod_target.include_in_build_config?(build_configuration) map(&:specs).flatten
end.map(&:specs).flatten
end end
result result
end end
......
...@@ -98,20 +98,29 @@ module Pod ...@@ -98,20 +98,29 @@ module Pod
@target.pod_targets = [@pod_target] @target.pod_targets = [@pod_target]
end end
it 'returns pod targets by build configuration' do describe 'with configuration dependent pod targets' do
pod_target_release = PodTarget.new([@spec], @target_definition, config.sandbox) before do
pod_target_release.expects(:include_in_build_config?).with('Debug').returns(false) @pod_target_release = PodTarget.new([@spec], @target_definition, config.sandbox)
pod_target_release.expects(:include_in_build_config?).with('Release').returns(true) @pod_target_release.expects(:include_in_build_config?).with('Debug').returns(false)
@target.pod_targets = [@pod_target, pod_target_release] @pod_target_release.expects(:include_in_build_config?).with('Release').returns(true)
@target.user_build_configurations = { @target.pod_targets = [@pod_target, @pod_target_release]
'Debug' => :debug, @target.user_build_configurations = {
'Release' => :release, 'Debug' => :debug,
} 'Release' => :release,
expected = { }
'Debug' => @pod_target.specs, end
'Release' => (@pod_target.specs + pod_target_release.specs),
} it 'returns pod targets for given build configuration' do
@target.specs_by_build_configuration.should == expected @target.pod_targets_for_build_configuration('Debug').should == [@pod_target]
@target.pod_targets_for_build_configuration('Release').should == [@pod_target, @pod_target_release]
end
it 'returns pod target specs by build configuration' do
@target.specs_by_build_configuration.should == {
'Debug' => @pod_target.specs,
'Release' => (@pod_target.specs + @pod_target_release.specs),
}
end
end end
it 'returns the specs of the Pods used by this aggregate target' do it 'returns the specs of the Pods used by this aggregate target' 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