Skip to content

Commit

Permalink
[CocoaPods#221] Completed merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Aug 6, 2012
1 parent d0a215c commit 68f22d1
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 57 deletions.
2 changes: 1 addition & 1 deletion lib/cocoapods/installer/target_installer.rb
Expand Up @@ -72,7 +72,7 @@ def install!(pods, sandbox)
end
@target.add_source_files(source_file_descriptions)

xcconfig.merge!('HEADER_SEARCH_PATHS' => quoted(sandbox.header_search_paths).join(" "))
xcconfig.merge!('HEADER_SEARCH_PATHS' => quoted(sandbox.build_headers.search_paths).join(" "))
# Indirect HEADER_SEARCH_PATHS, so that configure_build_configurations can override it
xcconfig.merge!('PODS_HEADER_SEARCH_PATHS' => quoted(sandbox.public_headers.search_paths).join(" "))

Expand Down
28 changes: 18 additions & 10 deletions lib/cocoapods/local_pod.rb
Expand Up @@ -229,14 +229,22 @@ def header_files_by_spec
result
end

# TODO: complete, fix and comment
# @return [Hash{Specification => Array<Pathname>}] The paths of the public
# header files grouped by {Specification}.
#
# @TODO: complete, fix and comment
# @TODO: decide a policy for subspecs
#
def public_header_files_by_specs
if specification.public_header_files.empty?
header_files_by_spec
else
options = {:glob => '*.h'}
paths_by_spec(:source_files, options)
cached_header_files_by_spec = header_files_by_spec
public_header_files = paths_by_spec(:source_files, :glob => '*.h')

result = {}
public_header_files.map do |spec, paths|
result[spec] = paths.empty? ? cached_header_files_by_spec[spec] : paths
end

result
end

# @return [Array<Pathname>] The paths of the resources.
Expand Down Expand Up @@ -332,14 +340,14 @@ def all_specs_public_header_files
# @return [void] Copies the pods headers to the sandbox.
#
def link_headers
@sandbox.add_header_search_path(headers_sandbox)

@sandbox.build_headers.add_search_path(headers_sandbox)
header_mappings.each do |namespaced_path, files|
@sandbox.build_header_storage.add_files(namespaced_path, files)
@sandbox.build_headers.add_files(namespaced_path, files)
end

@sandbox.public_headers.add_search_path(headers_sandbox)
public_header_mappings.each do |namespaced_path, files|
@sandbox.public_header_storage.add_files(namespaced_path, files)
@sandbox.public_headers.add_files(namespaced_path, files)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/cocoapods/sandbox.rb
Expand Up @@ -87,8 +87,8 @@ def search_paths
#
# @return [void]
#
def add_header_search_path(path)
@header_search_paths << Pathname.new(HEADERS_DIR) + path
def add_search_path(path)
@search_paths << path
end

def prepare_for_install
Expand Down
1 change: 1 addition & 0 deletions lib/cocoapods/specification.rb
Expand Up @@ -40,6 +40,7 @@ def initialize(parent = nil, name = nil)

# multi-platform attributes
%w[ source_files
public_header_files
resources
preserve_paths
exclude_header_search_paths
Expand Down
2 changes: 1 addition & 1 deletion spec/functional/command/spec_spec.rb
Expand Up @@ -34,7 +34,7 @@
spec.source.should == { :git => 'http://EXAMPLE/Bananas.git', :tag => '0.0.1' }
spec.description.should == 'A short description of Bananas.'
spec.source_files.should == ['Classes', 'Classes/**/*.{h,m}']
spec.public_header_files[:ios].should == []
spec.public_header_files.should == []
end

it "correctly creates a podspec from github" do
Expand Down
43 changes: 11 additions & 32 deletions spec/unit/local_pod_spec.rb
Expand Up @@ -11,26 +11,6 @@
copy_fixture_to_pod('banana-lib', @pod)
end

it "can link it's headers into the sandbox" do
@pod.link_headers
expected_header_path = @sandbox.build_headers.root + "BananaLib/Banana.h"
expected_header_path.should.be.symlink
File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read
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

it 'returns the Pod root directory path' do
@pod.root.should == @sandbox.root + 'BananaLib'
end
Expand Down Expand Up @@ -70,16 +50,6 @@
@pod.relative_header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")]
end

xit "returns the user header search paths" do
def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename
end
@spec.build_headers.search_paths.should == %w{
"$(PODS_ROOT)/Headers/SSZipArchive"
"$(PODS_ROOT)/Headers/SSZipArchive/ns"
}
end

it 'returns a list of header files by specification' do
files = @pod.header_files_by_spec[@pod.specifications.first].sort
files.should == [ @pod.root + "Classes/Banana.h" ]
Expand All @@ -100,7 +70,14 @@ def @spec.copy_header_mapping(from)

it "can link it's headers into the sandbox" do
@pod.link_headers
expected_header_path = @sandbox.headers_root + "BananaLib/Banana.h"
expected_header_path = @sandbox.build_headers.root + "BananaLib/Banana.h"
expected_header_path.should.be.symlink
File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read
end

it "can link it's public headers into the sandbox" do
@pod.link_headers
expected_header_path = @sandbox.public_headers.root + "BananaLib/Banana.h"
expected_header_path.should.be.symlink
File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read
end
Expand Down Expand Up @@ -321,8 +298,10 @@ def assert_array_equals(expected, computed)
"Chameleon/UIKit > UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h" ]
end

# This is done by the sandbox and this test should be moved
it "includes the sandbox of the pod's headers while linking" do
@sandbox.expects(:add_header_search_path).with(Pathname.new('Chameleon'))
@sandbox.build_headers.expects(:add_search_path).with(Pathname.new('Chameleon'))
@sandbox.public_headers.expects(:add_search_path).with(Pathname.new('Chameleon'))
@pod.link_headers
end
end
Expand Down
26 changes: 15 additions & 11 deletions spec/unit/sandbox_spec.rb
Expand Up @@ -24,25 +24,29 @@
end

it "returns it's headers root" do
@sandbox.build_headers.root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers"))
@sandbox.build_headers.root.should == Pathname.new(File.join(TMP_POD_ROOT, "BuildHeaders"))
end

it "returns it's public headers root" do
@sandbox.public_headers.root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers"))
end

it "can add namespaced headers to it's header path using symlinks and return the relative path" do
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/Headers")
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/BuildHeaders")
namespace_path = Pathname.new("ExampleLib")
relative_header_path = Pathname.new("ExampleLib/Headers/MyHeader.h")
relative_header_path = Pathname.new("ExampleLib/BuildHeaders/MyHeader.h")
File.open(@sandbox.root + relative_header_path, "w") { |file| file.write('hello') }
symlink_path = @sandbox.build_headers.add_file(namespace_path, relative_header_path)
symlink_path.should.be.symlink
File.read(symlink_path).should == 'hello'
end

it 'can add multiple headers at once and return the relative symlink paths' do
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/Headers")
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/BuildHeaders")
namespace_path = Pathname.new("ExampleLib")
relative_header_paths = [
Pathname.new("ExampleLib/Headers/MyHeader.h"),
Pathname.new("ExampleLib/Headers/MyOtherHeader.h")
Pathname.new("ExampleLib/BuildHeaders/MyHeader.h"),
Pathname.new("ExampleLib/BuildHeaders/MyOtherHeader.h")
]
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
Expand All @@ -55,21 +59,21 @@
end

it 'keeps a list of unique header search paths when headers are added' do
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/Headers")
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/BuildHeaders")
namespace_path = Pathname.new("ExampleLib")
relative_header_paths = [
Pathname.new("ExampleLib/Headers/MyHeader.h"),
Pathname.new("ExampleLib/Headers/MyOtherHeader.h")
Pathname.new("ExampleLib/BuildHeaders/MyHeader.h"),
Pathname.new("ExampleLib/BuildHeaders/MyOtherHeader.h")
]
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end
@sandbox.build_headers.add_files(namespace_path, relative_header_paths)
@sandbox.header_search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib")
@sandbox.build_headers.search_paths.should.include("${PODS_ROOT}/BuildHeaders/ExampleLib")
end

it 'always adds the Headers root to the header search paths' do
@sandbox.header_search_paths.should.include("${PODS_ROOT}/Headers")
@sandbox.build_headers.search_paths.should.include("${PODS_ROOT}/BuildHeaders")
end

it 'clears out its headers root when preparing for install' do
Expand Down

0 comments on commit 68f22d1

Please sign in to comment.