Commit 93a134ed authored by Fabio Pelosin's avatar Fabio Pelosin

[FileReferencesInstaller] Link headers globally, for now.

parent 09e97fba
...@@ -35,6 +35,7 @@ module Pod ...@@ -35,6 +35,7 @@ module Pod
def install! def install!
add_source_files_references add_source_files_references
add_resources_references add_resources_references
link_headers
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -90,6 +91,32 @@ module Pod ...@@ -90,6 +91,32 @@ module Pod
end end
end end
# Creates the link to the headers of the Pod in the sandbox.
#
# TODO: clean up
#
# @return [void]
#
def link_headers
UI.message "- Linking headers" do
file_accessors.each do |file_accessor|
headers_sandbox = Pathname.new(file_accessor.spec.root.name)
sandbox.build_headers.add_search_path(headers_sandbox)
sandbox.public_headers.add_search_path(headers_sandbox)
consumer = file_accessor.spec_consumer
header_mappings(headers_sandbox, consumer, file_accessor.headers, file_accessor.path_list.root).each do |namespaced_path, files|
sandbox.build_headers.add_files(namespaced_path, files)
end
header_mappings(headers_sandbox, consumer, file_accessor.public_headers, file_accessor.path_list.root).each do |namespaced_path, files|
sandbox.public_headers.add_files(namespaced_path, files)
end
end
end
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
private private
...@@ -103,6 +130,33 @@ module Pod ...@@ -103,6 +130,33 @@ module Pod
@file_accessors ||= libraries.map(&:file_accessors).flatten.compact @file_accessors ||= libraries.map(&:file_accessors).flatten.compact
end end
# Computes the destination sub-directory in the sandbox
#
# @param []
#
# @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.
#
# TODO This is being overridden in the RestKit 0.9.4 spec and that
# override should be fixed.
#
def header_mappings(headers_sandbox, consumer, headers, root)
dir = headers_sandbox
dir = dir + consumer.header_dir if consumer.header_dir
mappings = {}
headers.each do |header|
sub_dir = dir
if consumer.header_mappings_dir
sub_dir = sub_dir + header.relative_path_from(consumer.header_mappings_dir).dirname
end
mappings[sub_dir] ||= []
mappings[sub_dir] << header
end
mappings
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
......
...@@ -32,7 +32,6 @@ module Pod ...@@ -32,7 +32,6 @@ module Pod
UI.message "- Installing target `#{library.name}` #{library.platform}" do UI.message "- Installing target `#{library.name}` #{library.platform}" do
add_target add_target
add_files_to_build_phases add_files_to_build_phases
link_headers
create_suport_files_group create_suport_files_group
create_xcconfig_file create_xcconfig_file
...@@ -78,10 +77,10 @@ module Pod ...@@ -78,10 +77,10 @@ module Pod
@target.build_settings('Debug').merge!(settings) @target.build_settings('Debug').merge!(settings)
@target.build_settings('Release').merge!(settings) @target.build_settings('Release').merge!(settings)
library.user_build_configurations.each do |name, type| library.user_build_configurations.each do |lib_name, type|
unless @target.build_configurations.map(&:name).include?(name) unless @target.build_configurations.map(&:name).include?(lib_name)
build_config = project.new(Xcodeproj::Project::XCBuildConfiguration) build_config = project.new(Xcodeproj::Project::XCBuildConfiguration)
build_config.name = name build_config.name = lib_name
settings = @target.build_settings(type.to_s.capitalize) settings = @target.build_settings(type.to_s.capitalize)
build_config.build_settings = settings build_config.build_settings = settings
target.build_configurations << build_config target.build_configurations << build_config
...@@ -115,33 +114,7 @@ module Pod ...@@ -115,33 +114,7 @@ module Pod
target.add_file_references(file_refs, flags) target.add_file_references(file_refs, flags)
file_accessor.spec_consumer.frameworks.each do |framework| file_accessor.spec_consumer.frameworks.each do |framework|
framework_ref = project.add_system_framework(framework, target) project.add_system_framework(framework, target)
end
end
end
end
# Creates the link to the headers of the Pod in the sandbox.
#
# TODO: clean up
#
# @return [void]
#
def link_headers
UI.message "- Linking headers" do
library.file_accessors.each do |file_accessor|
headers_sandbox = Pathname.new(file_accessor.spec.root.name)
sandbox.build_headers.add_search_path(headers_sandbox)
sandbox.public_headers.add_search_path(headers_sandbox)
consumer = file_accessor.spec_consumer
header_mappings(headers_sandbox, consumer, file_accessor.headers, file_accessor.path_list.root).each do |namespaced_path, files|
sandbox.build_headers.add_files(namespaced_path, files)
end
header_mappings(headers_sandbox, consumer, file_accessor.public_headers, file_accessor.path_list.root).each do |namespaced_path, files|
sandbox.public_headers.add_files(namespaced_path, files)
end end
end end
end end
...@@ -391,34 +364,6 @@ module Pod ...@@ -391,34 +364,6 @@ module Pod
flags = flags * " " flags = flags * " "
end end
# Computes the destination sub-directory in the sandbox
#
# @param []
#
# @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.
#
# TODO This is being overridden in the RestKit 0.9.4 spec and that
# override should be fixed.
#
def header_mappings(headers_sandbox, consumer, headers, root)
dir = headers_sandbox
dir = dir + consumer.header_dir if consumer.header_dir
mappings = {}
headers.each do |header|
relative_path = header.relative_path_from(root)
sub_dir = dir
if consumer.header_mappings_dir
sub_dir = sub_dir + header.relative_path_from(consumer.header_mappings_dir).dirname
end
mappings[sub_dir] ||= []
mappings[sub_dir] << header
end
mappings
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
......
...@@ -32,6 +32,25 @@ module Pod ...@@ -32,6 +32,25 @@ module Pod
file_ref.should.be.not.nil file_ref.should.be.not.nil
file_ref.path.should == "../../spec/fixtures/banana-lib/Resources/logo-sidebar.png" file_ref.path.should == "../../spec/fixtures/banana-lib/Resources/logo-sidebar.png"
end end
it "links the build headers" do
@installer.install!
headers_root = config.sandbox.build_headers.root
public_header = headers_root+ 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist
private_header.should.exist
end
it "links the public headers" do
@installer.install!
headers_root = config.sandbox.public_headers.root
public_header = headers_root+ 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist
private_header.should.not.exist
end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
...@@ -212,32 +212,6 @@ module Pod ...@@ -212,32 +212,6 @@ module Pod
#--------------------------------------------------------------------------------# #--------------------------------------------------------------------------------#
#--------------------------------------#
describe "Headers" do
it "links the headers used to build the Pod library" do
@installer.install!
headers_root = config.sandbox.build_headers.root
public_header = headers_root+ 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist
private_header.should.exist
end
it "links the public headers" do
@installer.install!
headers_root = config.sandbox.public_headers.root
public_header = headers_root+ 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist
private_header.should.not.exist
end
end
#--------------------------------------#
describe "concerning ARC before and after iOS 6.0 and OS X 10.8" do describe "concerning ARC before and after iOS 6.0 and OS X 10.8" do
before do before do
@spec = Pod::Spec.new @spec = Pod::Spec.new
......
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