Commit c74fc01a authored by Fabio Pelosin's avatar Fabio Pelosin

[TargetInstaller] Add source files in batch.

parent f4326c73
......@@ -62,13 +62,15 @@ module Pod
@target = @project.add_pod_target(@target_definition.label, @target_definition.platform)
source_files_description = []
pods.each do |pod|
xcconfig.merge!(pod.xcconfig)
pod.add_to_target(@target)
source_files_description += pod.source_files_description
# TODO: this doesn't need to be done here, it has nothing to do with the target
pod.link_headers
end
@target.add_source_files(source_files_description)
xcconfig.merge!('HEADER_SEARCH_PATHS' => quoted(sandbox.header_search_paths).join(" "))
......
......@@ -328,13 +328,19 @@ module Pod
#
# @return [void] Adds the pods source files to a given target.
#
def add_to_target(target)
def source_files_description
result = []
source_files_by_spec.each do | spec, files |
compiler_flags = spec.compiler_flags.strip
files.each do |file|
file = file.relative_path_from(@sandbox.root)
target.add_source_file(file, nil, spec.compiler_flags.strip)
description = {}
description[:path] = file
description[:compiler_flags] = compiler_flags unless compiler_flags.empty?
result << description
end
end
result
end
# @return Whether the pod requires ARC.
......
......@@ -40,7 +40,7 @@ describe Pod::Installer::TargetInstaller do
end
it 'adds each pod to the static library target' do
@pods[0].expects(:add_to_target).with(instance_of(Xcodeproj::Project::Object::PBXNativeTarget))
@pods[0].expects(:source_files_description).returns([])
do_install!
end
......
......@@ -75,17 +75,16 @@ describe Pod::LocalPod do
end
it "can add it's source files to an Xcode project target" do
target = mock('target')
target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.h"), anything, anything)
target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.m"), anything, anything)
@pod.add_to_target(target)
@pod.source_files_description.should == [
{:path => Pathname.new("BananaLib/Classes/Banana.h")},
{:path => Pathname.new("BananaLib/Classes/Banana.m")}]
end
it "can add it's source files to a target with any specially configured compiler flags" do
@pod.top_specification.compiler_flags = '-d some_flag'
target = mock('target')
target.expects(:add_source_file).twice.with(anything, anything, "-d some_flag")
@pod.add_to_target(target)
@pod.source_files_description.should == [
{:path => Pathname.new("BananaLib/Classes/Banana.h"), :compiler_flags => '-d some_flag'},
{:path => Pathname.new("BananaLib/Classes/Banana.m"), :compiler_flags => '-d some_flag'}]
end
it "returns the platform" 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