Commit 30ebfc4c authored by Eloy Durán's avatar Eloy Durán

[Sandbox] Symlink vendored framework headers into the public headers dir.

Fixes #1992.
parent 7bfc1a79
......@@ -117,11 +117,15 @@ module Pod
library.build_headers.add_search_path(headers_sandbox, library.platform)
sandbox.public_headers.add_search_path(headers_sandbox, library.platform)
header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files|
header_mappings(headers_sandbox, file_accessor, file_accessor.headers, false).each do |namespaced_path, files|
library.build_headers.add_files(namespaced_path, files, library.platform)
end
header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files|
header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers, false).each do |namespaced_path, files|
sandbox.public_headers.add_files(namespaced_path, files, library.platform)
end
header_mappings(headers_sandbox, file_accessor, file_accessor.vendored_frameworks_headers, true).each do |namespaced_path, files|
sandbox.public_headers.add_files(namespaced_path, files, library.platform)
end
end
......@@ -177,11 +181,15 @@ module Pod
# @param [Array<Pathname>] headers
# The absolute paths of the headers which need to be mapped.
#
# @param [Boolean] framework_headers
# Whether or not these headers should get an extra framework name
# namespace. E.g. `Bananas/Bananas.h` instead of `Bananas.h`.
#
# @return [Hash{Pathname => Array<Pathname>}] A hash containing the
# headers folders as the keys and the absolute paths of the
# header files as the values.
#
def header_mappings(headers_sandbox, file_accessor, headers)
def header_mappings(headers_sandbox, file_accessor, headers, framework_headers)
consumer = file_accessor.spec_consumer
dir = headers_sandbox
dir += consumer.header_dir if consumer.header_dir
......@@ -189,7 +197,12 @@ module Pod
mappings = {}
headers.each do |header|
sub_dir = dir
if consumer.header_mappings_dir
if framework_headers
framework_filename = header.each_filename.find do |filename|
File.extname(filename) == '.framework'
end
sub_dir += File.basename(framework_filename, '.framework')
elsif consumer.header_mappings_dir
header_mappings_dir = file_accessor.path_list.root + consumer.header_mappings_dir
relative_path = header.relative_path_from(header_mappings_dir)
sub_dir += relative_path.dirname
......
......@@ -118,6 +118,16 @@ module Pod
paths_for_attribute(:vendored_frameworks, true)
end
# @return [Array<Pathname>] The paths of the framework headers that come
# shipped with the Pod.
#
def vendored_frameworks_headers
vendored_frameworks.map do |framework|
headers_dir = (framework + 'Headers').realpath
Pathname.glob(headers_dir + GLOB_PATTERNS[:public_header_files])
end.flatten.uniq
end
# @return [Array<Pathname>] The paths of the library bundles that come
# shipped with the Pod.
#
......
......@@ -51,22 +51,26 @@ module Pod
file_ref.path.should == 'Resources/logo-sidebar.png'
end
it 'links the build headers' do
it 'links the headers required for building the pod target' do
@installer.install!
headers_root = @pod_target.build_headers.root
public_header = headers_root + 'BananaLib/Banana.h'
public_header = headers_root + 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h'
framework_header = headers_root + 'BananaLib/Bananalib/Bananalib.h'
public_header.should.exist
private_header.should.exist
framework_header.should.not.exist
end
it 'links the public headers' do
it 'links the public headers meant for the user' do
@installer.install!
headers_root = config.sandbox.public_headers.root
public_header = headers_root + 'BananaLib/Banana.h'
public_header = headers_root + 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h'
framework_header = headers_root + 'BananaLib/Bananalib/Bananalib.h'
public_header.should.exist
private_header.should.not.exist
framework_header.should.exist
end
end
......@@ -98,9 +102,9 @@ module Pod
it 'returns the header mappings' do
headers_sandbox = Pathname.new('BananaLib')
headers = [Pathname.new('BananaLib/Banana.h')]
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers)
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers, false)
mappings.should == {
headers_sandbox => [Pathname.new('BananaLib/Banana.h')],
headers_sandbox => headers,
}
end
......@@ -108,9 +112,9 @@ module Pod
headers_sandbox = Pathname.new('BananaLib')
headers = [Pathname.new('BananaLib/Banana.h')]
@file_accessor.spec_consumer.stubs(:header_dir).returns('Sub_dir')
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers)
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers, false)
mappings.should == {
(headers_sandbox + 'Sub_dir') => [Pathname.new('BananaLib/Banana.h')],
(headers_sandbox + 'Sub_dir') => headers,
}
end
......@@ -120,12 +124,21 @@ module Pod
header_2 = @file_accessor.root + 'BananaLib/sub_dir/dir_2/banana_2.h'
headers = [header_1, header_2]
@file_accessor.spec_consumer.stubs(:header_mappings_dir).returns('BananaLib/sub_dir')
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers)
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers, false)
mappings.should == {
(headers_sandbox + 'dir_1') => [header_1],
(headers_sandbox + 'dir_2') => [header_2],
}
end
it 'takes into account the framework name required in the namespace' do
headers_sandbox = Pathname.new('BananaLib')
headers = [Pathname.new('BananaLib/Bananalib.framework/Versions/A/Headers/Bananalib.h')]
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers, true)
mappings.should == {
(headers_sandbox + 'Bananalib') => headers,
}
end
end
end
......
......@@ -108,6 +108,12 @@ module Pod
@accessor.vendored_frameworks.should.include?(@root + 'Bananalib.framework')
end
it 'returns the paths of the framework headers' do
@accessor.vendored_frameworks_headers.should == [
@root + 'Bananalib.framework/Versions/A/Headers/Bananalib.h',
]
end
it 'returns the paths of the library files' do
@accessor.vendored_libraries.should.include?(@root + 'libBananalib.a')
end
......
......@@ -16,6 +16,7 @@ module Pod
end
expected = %w(
BananaLib.podspec
Bananalib.framework/Versions/A/Headers/Bananalib.h
Classes/Banana.h
Classes/Banana.m
Classes/BananaLib.pch
......@@ -37,7 +38,19 @@ module Pod
dirs.reject! do |f|
f.include?('libPusher') || f.include?('.git')
end
dirs.sort.should == %w( Bananalib.framework Classes Resources Resources/sub_dir sub-dir sub-dir/sub-dir-2 )
dirs.sort.should == %w(
Bananalib.framework
Bananalib.framework/Headers
Bananalib.framework/Versions
Bananalib.framework/Versions/A
Bananalib.framework/Versions/A/Headers
Bananalib.framework/Versions/Current
Classes
Resources
Resources/sub_dir
sub-dir
sub-dir/sub-dir-2
)
end
it 'handles directories with glob metacharacters' 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