Commit 25e2940f authored by Marius Rackwitz's avatar Marius Rackwitz

[PodTarget] Make #include_in_build_config? ready for deduplication

parent 142b23c3
...@@ -101,7 +101,7 @@ module Pod ...@@ -101,7 +101,7 @@ module Pod
end end
resources_by_config = {} resources_by_config = {}
target.user_build_configurations.keys.each do |config| target.user_build_configurations.keys.each do |config|
file_accessors = library_targets.select { |t| t.include_in_build_config?(config) }.flat_map(&:file_accessors) file_accessors = library_targets.select { |t| t.include_in_build_config?(target_definition, config) }.flat_map(&:file_accessors)
resource_paths = file_accessors.flat_map { |accessor| accessor.resources.flat_map { |res| res.relative_path_from(project.path.dirname) } } resource_paths = file_accessors.flat_map { |accessor| accessor.resources.flat_map { |res| res.relative_path_from(project.path.dirname) } }
resource_bundles = file_accessors.flat_map { |accessor| accessor.resource_bundles.keys.map { |name| "${BUILT_PRODUCTS_DIR}/#{name.shellescape}.bundle" } } resource_bundles = file_accessors.flat_map { |accessor| accessor.resource_bundles.keys.map { |name| "${BUILT_PRODUCTS_DIR}/#{name.shellescape}.bundle" } }
resources_by_config[config] = (resource_paths + resource_bundles).uniq resources_by_config[config] = (resource_paths + resource_bundles).uniq
...@@ -139,7 +139,7 @@ module Pod ...@@ -139,7 +139,7 @@ module Pod
frameworks_by_config = {} frameworks_by_config = {}
target.user_build_configurations.keys.each do |config| target.user_build_configurations.keys.each do |config|
frameworks_by_config[config] = target.pod_targets.select do |pod_target| frameworks_by_config[config] = target.pod_targets.select do |pod_target|
pod_target.include_in_build_config?(config) && pod_target.should_build? pod_target.include_in_build_config?(target_definition, config) && pod_target.should_build?
end.map do |pod_target| end.map do |pod_target|
"#{target_definition.label}/#{pod_target.product_name}" "#{target_definition.label}/#{pod_target.product_name}"
end end
......
...@@ -94,7 +94,7 @@ module Pod ...@@ -94,7 +94,7 @@ module Pod
# #
def pod_targets_for_build_configuration(build_configuration) def pod_targets_for_build_configuration(build_configuration)
pod_targets.select do |pod_target| pod_targets.select do |pod_target|
pod_target.include_in_build_config?(build_configuration) pod_target.include_in_build_config?(target_definition, build_configuration)
end end
end end
......
...@@ -121,13 +121,16 @@ module Pod ...@@ -121,13 +121,16 @@ module Pod
end end
# Checks if the target should be included in the build configuration with # Checks if the target should be included in the build configuration with
# the given name. # the given name of a given target definition.
#
# @param [TargetDefinition] target_definition
# The target definition to check.
# #
# @param [String] configuration_name # @param [String] configuration_name
# The name of the build configuration. # The name of the build configuration.
# #
def include_in_build_config?(configuration_name) def include_in_build_config?(target_definition, configuration_name)
whitelists = target_definition_dependencies.map do |dependency| whitelists = target_definition_dependencies(target_definition).map do |dependency|
target_definition.pod_whitelisted_for_configuration?(dependency.name, configuration_name) target_definition.pod_whitelisted_for_configuration?(dependency.name, configuration_name)
end.uniq end.uniq
...@@ -145,12 +148,15 @@ module Pod ...@@ -145,12 +148,15 @@ module Pod
private private
# @param [TargetDefinition] target_definition
# The target definition to check.
#
# @return [Array<Dependency>] The dependency of the target definition for # @return [Array<Dependency>] The dependency of the target definition for
# this Pod. Return an empty array if the Pod is not a direct # this Pod. Return an empty array if the Pod is not a direct
# dependency of the target definition but the dependency of one or # dependency of the target definition but the dependency of one or
# more Pods. # more Pods.
# #
def target_definition_dependencies def target_definition_dependencies(target_definition)
target_definition.dependencies.select do |dependency| target_definition.dependencies.select do |dependency|
Specification.root_name(dependency.name) == pod_name Specification.root_name(dependency.name) == pod_name
end end
......
...@@ -97,8 +97,8 @@ module Pod ...@@ -97,8 +97,8 @@ module Pod
describe 'with configuration dependent pod targets' do describe 'with configuration dependent pod targets' do
before do before do
@pod_target_release = PodTarget.new([@spec], @target_definition, config.sandbox) @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(@target_definition, 'Debug').returns(false)
@pod_target_release.expects(:include_in_build_config?).with('Release').returns(true) @pod_target_release.expects(:include_in_build_config?).with(@target_definition, 'Release').returns(true)
@target.pod_targets = [@pod_target, @pod_target_release] @target.pod_targets = [@pod_target, @pod_target_release]
@target.user_build_configurations = { @target.user_build_configurations = {
'Debug' => :debug, 'Debug' => :debug,
......
...@@ -63,13 +63,13 @@ module Pod ...@@ -63,13 +63,13 @@ module Pod
it 'returns whether it is whitelisted in a build configuration' do it 'returns whether it is whitelisted in a build configuration' do
@target_definition.store_pod('BananaLib') @target_definition.store_pod('BananaLib')
@target_definition.whitelist_pod_for_configuration('BananaLib', 'debug') @target_definition.whitelist_pod_for_configuration('BananaLib', 'debug')
@pod_target.include_in_build_config?('Debug').should.be.true @pod_target.include_in_build_config?(@target_definition, 'Debug').should.be.true
@pod_target.include_in_build_config?('Release').should.be.false @pod_target.include_in_build_config?(@target_definition, 'Release').should.be.false
end end
it 'is whitelisted on all build configurations of it is a dependency of other Pods' do it 'is whitelisted on all build configurations of it is a dependency of other Pods' do
@pod_target.include_in_build_config?('Debug').should.be.true @pod_target.include_in_build_config?(@target_definition, 'Debug').should.be.true
@pod_target.include_in_build_config?('Release').should.be.true @pod_target.include_in_build_config?(@target_definition, 'Release').should.be.true
end end
it 'raises if a Pod is whitelisted for different build configurations' do it 'raises if a Pod is whitelisted for different build configurations' do
...@@ -77,7 +77,7 @@ module Pod ...@@ -77,7 +77,7 @@ module Pod
@target_definition.store_pod('BananaLib/Subspec') @target_definition.store_pod('BananaLib/Subspec')
@target_definition.whitelist_pod_for_configuration('BananaLib', 'debug') @target_definition.whitelist_pod_for_configuration('BananaLib', 'debug')
message = should.raise Informative do message = should.raise Informative do
@pod_target.include_in_build_config?('release').should.be.true @pod_target.include_in_build_config?(@target_definition, 'release').should.be.true
end.message end.message
message.should.match /subspecs across different build configurations/ message.should.match /subspecs across different build configurations/
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