Commit cccca4ff authored by Fabio Pelosin's avatar Fabio Pelosin

[AggretateTarget] Expose specs by build configuration

parent b3a77a6f
require 'active_support/core_ext/string/strip'
module Pod
module Generator
......@@ -23,14 +25,15 @@ module Pod
#
class TargetEnvironmentHeader
# @return [Array<LocalPod>] the specifications installed for the target.
# @return [Hash{String => LocalPod}] the specifications installed for
# the target by build configuration name.
#
attr_reader :specs
attr_reader :specs_by_build_configuration
# @param [Array<LocalPod>] pods @see pods
#
def initialize(specs)
@specs = specs
def initialize(specs_by_build_configuration)
@specs_by_build_configuration = specs_by_build_configuration
end
# Generates and saves the file.
......@@ -50,7 +53,7 @@ module Pod
source.puts "// project."
source.puts
source.puts
specs.each do |spec|
common_specs(specs_by_build_configuration).each do |spec|
spec_name = safe_spec_name(spec.name)
source.puts "// #{spec.name}"
source.puts "#define COCOAPODS_POD_AVAILABLE_#{spec_name}"
......@@ -79,6 +82,14 @@ module Pod
spec_name.gsub(/[^\w]/,'_')
end
def common_specs(specs_by_build_configuration)
result = specs_by_build_configuration.values.flatten.uniq
specs_by_build_configuration.values.each do |build_configuration_specs|
result = result & build_configuration_specs
end
result
end
#-----------------------------------------------------------------------#
end
......
......@@ -50,7 +50,7 @@ module Pod
def create_target_environment_header
path = library.target_environment_header_path
UI.message "- Generating target environment header at #{UI.path(path)}" do
generator = Generator::TargetEnvironmentHeader.new(library.pod_targets.map { |l| l.specs }.flatten)
generator = Generator::TargetEnvironmentHeader.new(library.specs_by_build_configuration)
generator.save_as(path)
add_file_to_support_group(path)
end
......
......@@ -64,6 +64,19 @@ module Pod
pod_targets.map(&:specs).flatten
end
# @return [Hash{Symbol => Array<PodTarget>}] The pod targets for each
# build configuration.
#
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
end
result
end
# @return [Array<Specification::Consumer>] The consumers of the Pod.
#
def spec_consumers
......
......@@ -4,7 +4,7 @@ describe Pod::Generator::TargetEnvironmentHeader do
before do
specification = fixture_spec('banana-lib/BananaLib.podspec')
@gen = Pod::Generator::TargetEnvironmentHeader.new([specification])
@gen = Pod::Generator::TargetEnvironmentHeader.new({'Debug' => [specification]})
end
it "generates a header files which include macro definitions for installed Pods" do
......
......@@ -71,12 +71,32 @@ module Pod
describe "Pod targets" do
before do
spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new('Pods', nil)
pod_target = PodTarget.new([spec], target_definition, config.sandbox)
@target = AggregateTarget.new(target_definition, config.sandbox)
@spec = fixture_spec('banana-lib/BananaLib.podspec')
@target_definition = Podfile::TargetDefinition.new('Pods', nil)
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox)
@target = AggregateTarget.new(@target_definition, config.sandbox)
@target.stubs(:platform).returns(:ios)
@target.pod_targets = [pod_target]
@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]
@target.user_build_configurations = {
"Debug" => :debug,
"Release" => :release
}
expected = {
"Debug" => @pod_target.specs,
"Release" => (@pod_target.specs + pod_target_release.specs)
}
@target.specs_by_build_configuration.should == expected
end
it "returns the specs of the Pods used by this aggregate target" do
@target.specs.map(&:name).should == ["BananaLib"]
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