Commit 8390e00b authored by Luke Redpath's avatar Luke Redpath

Encapsulate adding a pod's source files to an Xcode target within LocalPod.

parent ef25e3f1
...@@ -7,5 +7,5 @@ group :development do ...@@ -7,5 +7,5 @@ group :development do
gem "guard-bacon" gem "guard-bacon"
gem "rb-fsevent" gem "rb-fsevent"
gem "growl" gem "growl"
gem "mocha" gem "mocha-on-bacon"
end end
...@@ -11,6 +11,8 @@ GEM ...@@ -11,6 +11,8 @@ GEM
metaclass (0.0.1) metaclass (0.0.1)
mocha (0.10.4) mocha (0.10.4)
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
mocha-on-bacon (0.2.0)
mocha (>= 0.9.8)
rake (0.9.2.2) rake (0.9.2.2)
rb-fsevent (0.9.0) rb-fsevent (0.9.0)
schmurfy-bacon (1.2.1) schmurfy-bacon (1.2.1)
...@@ -26,6 +28,6 @@ DEPENDENCIES ...@@ -26,6 +28,6 @@ DEPENDENCIES
growl growl
guard guard
guard-bacon guard-bacon
mocha mocha-on-bacon
rake rake
rb-fsevent rb-fsevent
...@@ -66,11 +66,7 @@ module Pod ...@@ -66,11 +66,7 @@ module Pod
pods.each do |pod| pods.each do |pod|
xcconfig.merge!(pod.specification.xcconfig) xcconfig.merge!(pod.specification.xcconfig)
pod.add_to_target(@target)
pod.implementation_files.each do |file|
@target.add_source_file(file, nil, pod.specification.compiler_flags)
end
pod.link_headers pod.link_headers
end end
......
...@@ -50,10 +50,6 @@ module Pod ...@@ -50,10 +50,6 @@ module Pod
def resources def resources
expanded_paths(specification.resources, :relative_to_sandbox => true) expanded_paths(specification.resources, :relative_to_sandbox => true)
end end
def implementation_files
source_files.select { |f| f.extname != '.h' }
end
def header_files def header_files
source_files.select { |f| f.extname == '.h' } source_files.select { |f| f.extname == '.h' }
...@@ -65,8 +61,18 @@ module Pod ...@@ -65,8 +61,18 @@ module Pod
end end
end end
def add_to_target(target)
implementation_files.each do |file|
target.add_source_file(file, nil, specification.compiler_flags)
end
end
private private
def implementation_files
source_files.select { |f| f.extname != '.h' }
end
def relative_root def relative_root
root.relative_path_from(@sandbox.root) root.relative_path_from(@sandbox.root)
end end
......
...@@ -121,8 +121,8 @@ module Pod ...@@ -121,8 +121,8 @@ module Pod
attr_writer :compiler_flags attr_writer :compiler_flags
def compiler_flags def compiler_flags
flags = "#{@compiler_flags} " flags = "#{@compiler_flags}"
flags << '-fobjc-arc' if requires_arc flags << ' -fobjc-arc' if requires_arc
flags flags
end end
...@@ -265,10 +265,6 @@ module Pod ...@@ -265,10 +265,6 @@ module Pod
files files
end end
def implementation_files
expanded_source_files.select { |f| f.extname != '.h' }
end
# Returns only the header files of this pod. # Returns only the header files of this pod.
def header_files def header_files
expanded_source_files.select { |f| f.extname == '.h' } expanded_source_files.select { |f| f.extname == '.h' }
......
require 'rubygems' require 'rubygems'
require 'bacon' require 'bacon'
require 'mocha' require 'mocha-on-bacon'
require 'pathname' require 'pathname'
ROOT = Pathname.new(File.expand_path('../../', __FILE__)) ROOT = Pathname.new(File.expand_path('../../', __FILE__))
......
...@@ -45,10 +45,6 @@ describe Pod::LocalPod do ...@@ -45,10 +45,6 @@ describe Pod::LocalPod do
@pod.resources.should == [Pathname.new("BananaLib/Resources/logo-sidebar.png")] @pod.resources.should == [Pathname.new("BananaLib/Resources/logo-sidebar.png")]
end end
it 'returns a list of implementation files' do
@pod.implementation_files.should == [Pathname.new("BananaLib/Classes/Banana.m")]
end
it 'returns a list of header files' do it 'returns a list of header files' do
@pod.header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")] @pod.header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")]
end end
...@@ -70,4 +66,17 @@ describe Pod::LocalPod do ...@@ -70,4 +66,17 @@ describe Pod::LocalPod do
File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read
end 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.m"), anything, anything)
@pod.add_to_target(target)
end
it "can add it's source files to a target with any specially configured compiler flags" do
@pod.specification.compiler_flags = '-d some_flag'
target = mock('target')
target.expects(:add_source_file).with(anything, anything, "-d some_flag")
@pod.add_to_target(target)
end
end end
...@@ -160,12 +160,6 @@ describe "A Pod::Specification, with installed source," do ...@@ -160,12 +160,6 @@ describe "A Pod::Specification, with installed source," do
@spec.header_files.sort.should == files.sort @spec.header_files.sort.should == files.sort
end end
it "returns the list of implementation files" do
files = @destroot.glob('**/*.{c,m}')
files = files.map { |file| file.relative_path_from(config.project_pods_root) }
@spec.implementation_files.sort.should == files.sort
end
it "returns a hash of mappings from the pod's destroot to its header dirs, which by default is just the pod's header dir" do it "returns a hash of mappings from the pod's destroot to its header dirs, which by default is just the pod's header dir" do
@spec.copy_header_mappings.size.should == 1 @spec.copy_header_mappings.size.should == 1
@spec.copy_header_mappings[Pathname.new('SSZipArchive')].sort.should == %w{ @spec.copy_header_mappings[Pathname.new('SSZipArchive')].sort.should == %w{
......
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