Commit 0aea0bef authored by Gwendal Roué's avatar Gwendal Roué

[#221] code cleanup

parent 5a2c29c0
......@@ -73,7 +73,7 @@ module Pod
# Indirect HEADER_SEARCH_PATHS, so that configure_build_configurations can override it
xcconfig.merge!('HEADER_SEARCH_PATHS' => '${PODS_HEADER_SEARCH_PATHS}')
xcconfig.merge!('PODS_HEADER_SEARCH_PATHS' => quoted(sandbox.public_header_storage.search_paths).join(" "))
xcconfig.merge!('PODS_HEADER_SEARCH_PATHS' => quoted(sandbox.public_headers.search_paths).join(" "))
support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label)
support_files_group.create_files(target_support_files)
......@@ -89,7 +89,7 @@ module Pod
config.build_settings['OTHER_LDFLAGS'] = ''
config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name
config.build_settings['PODS_ROOT'] = '${SRCROOT}'
config.build_settings['PODS_HEADER_SEARCH_PATHS'] = quoted(sandbox.build_header_storage.search_paths).join(" ")
config.build_settings['PODS_HEADER_SEARCH_PATHS'] = quoted(sandbox.build_headers.search_paths).join(" ")
end
end
......
......@@ -85,10 +85,10 @@ module Pod
def link_headers
copy_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
copy_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
......
......@@ -3,17 +3,16 @@ require 'fileutils'
module Pod
class Sandbox
attr_reader :root
attr_reader :build_header_storage
attr_reader :public_header_storage
attr_reader :build_headers
attr_reader :public_headers
PUBLIC_HEADERS_DIR = "Headers"
BUILD_HEADERS_DIR = "BuildHeaders"
PUBLIC_HEADERS_DIR = "Headers"
def initialize(path)
@root = Pathname.new(path)
@build_header_storage = HeaderStorage.new(self, BUILD_HEADERS_DIR)
@public_header_storage = HeaderStorage.new(self, PUBLIC_HEADERS_DIR)
@build_headers = HeadersDirectory.new(self, BUILD_HEADERS_DIR)
@public_headers = HeadersDirectory.new(self, PUBLIC_HEADERS_DIR)
FileUtils.mkdir_p(@root)
end
......@@ -26,8 +25,8 @@ module Pod
end
def prepare_for_install
build_header_storage.prepare_for_install
public_header_storage.prepare_for_install
build_headers.prepare_for_install
public_headers.prepare_for_install
end
def podspec_for_name(name)
......@@ -44,35 +43,35 @@ module Pod
end
end
end
class HeaderStorage
class HeadersDirectory
def initialize(sandbox, base_dir)
@sandbox = sandbox
@base_dir = base_dir
@search_paths = [base_dir]
end
def root
@sandbox.root + @base_dir
end
def add_file(namespace_path, relative_header_path)
namespaced_header_path = @sandbox.root + @base_dir + namespace_path
namespaced_header_path = root + namespace_path
namespaced_header_path.mkpath unless File.exist?(namespaced_header_path)
source = (@sandbox.root + relative_header_path).relative_path_from(namespaced_header_path)
Dir.chdir(namespaced_header_path) { FileUtils.ln_sf(source, relative_header_path.basename)}
@search_paths << namespaced_header_path.relative_path_from(@sandbox.root)
namespaced_header_path + relative_header_path.basename
end
def add_files(namespace_path, relative_header_paths)
relative_header_paths.map { |path| add_file(namespace_path, path) }
end
def search_paths
@search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" }
end
def prepare_for_install
root.rmtree if root.exist?
end
......
......@@ -51,7 +51,7 @@ describe Pod::Installer::TargetInstaller do
it 'adds the sandbox header search paths to the xcconfig, with quotes' do
do_install!
@installer.xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include("\"#{@sandbox.build_header_storage.search_paths.join('" "')}\"")
@installer.xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include("\"#{@sandbox.build_headers.search_paths.join('" "')}\"")
end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
......
......@@ -61,7 +61,7 @@ describe Pod::LocalPod do
it "can link it's headers into the sandbox" do
@pod.link_headers
expected_header_path = @sandbox.build_header_storage.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
......@@ -147,7 +147,7 @@ describe "A Pod::LocalPod, with installed source," do
def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename
end
@spec.build_header_storage.search_paths.should == %w{
@spec.build_headers.search_paths.should == %w{
"$(PODS_ROOT)/Headers/SSZipArchive"
"$(PODS_ROOT)/Headers/SSZipArchive/ns"
}
......@@ -158,7 +158,7 @@ describe "A Pod::LocalPod, with installed source," do
def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename
end
@spec.build_header_storage.search_paths.should == %w{
@spec.build_headers.search_paths.should == %w{
"$(PODS_ROOT)/Headers/AnotherRoot"
"$(PODS_ROOT)/Headers/AnotherRoot/ns"
}
......
......@@ -24,7 +24,7 @@ describe Pod::Sandbox do
end
it "returns it's headers root" do
@sandbox.build_header_storage.root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers"))
@sandbox.build_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
......@@ -32,7 +32,7 @@ describe Pod::Sandbox do
namespace_path = Pathname.new("ExampleLib")
relative_header_path = Pathname.new("ExampleLib/Headers/MyHeader.h")
File.open(@sandbox.root + relative_header_path, "w") { |file| file.write('hello') }
symlink_path = @sandbox.build_header_storage.add_file(namespace_path, relative_header_path)
symlink_path = @sandbox.build_headers.add_file(namespace_path, relative_header_path)
symlink_path.should.be.symlink
File.read(symlink_path).should == 'hello'
end
......@@ -47,7 +47,7 @@ describe Pod::Sandbox do
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end
symlink_paths = @sandbox.build_header_storage.add_files(namespace_path, relative_header_paths)
symlink_paths = @sandbox.build_headers.add_files(namespace_path, relative_header_paths)
symlink_paths.each do |path|
path.should.be.symlink
File.read(path).should == "hello"
......@@ -64,7 +64,7 @@ describe Pod::Sandbox do
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end
@sandbox.build_header_storage.add_files(namespace_path, relative_header_paths)
@sandbox.build_headers.add_files(namespace_path, relative_header_paths)
@sandbox.header_search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib")
end
......@@ -74,6 +74,6 @@ describe Pod::Sandbox do
it 'clears out its headers root when preparing for install' do
@sandbox.prepare_for_install
@sandbox.build_header_storage.root.should.not.exist
@sandbox.build_headers.root.should.not.exist
end
end
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