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